All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/17] staging: Assorted lustre cleanup
@ 2018-03-29  4:26 ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

I'm currently working on converting lustre to use
rhashtables instead of its own resizeable hash tables.
That is progressing well, but I need some changes to
rhashtable first, and that will take a little while.
So here are some other patches.
Some are cleanups related to hashtables,
some are related to measuring time in jiffies
and some are random other things I found as I was looking
at stuff.

James, if this jiffie stuff conflicts with your time-keeping stuff, we
can just drop it.  Last time I cleaned up jiffie-related code you
said it didn't conflict significantly, so I'm hoping this won't
either.

Thanks,
NeilBrown


---

NeilBrown (17):
      staging: lustre: remove invariant in cl_io_read_ahead()
      staging: lustre: remove unused ldlm_completion_ast_async()
      staging: lustre: LNET excludes USERIO
      staging: lustre: remove unused hash tables.
      staging: lustre: remove unneeded include.
      staging: lustre: tidy up ldlm_resource_putref()
      staging: lustre: ldlm: free resource when ldlm_lock_create() fails.
      staging: lustre: add container_of_safe()
      staging: lustre: cfs_time_current() -> jiffies.
      staging: lustre: libcfs: discard cfs_time_add/sub
      staging: lustre: libcfs: discard cfs_time_shift().
      staging: lustre: libcfs: discard cfs_time_after()
      staging: lustre: libcfs: remove cfs_timeout_cap()
      staging: lustre: discard cfs_duration_sec()
      staging: lustre: discard cfs_time_before_64()
      staging: lustre: discard linux-time.h
      staging: lustre: remove cruft from libcfs/linux/libcfs.h


 .../staging/lustre/include/linux/libcfs/curproc.h  |    2 
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   17 +--
 .../lustre/include/linux/libcfs/libcfs_time.h      |   79 ---------------
 .../lustre/include/linux/libcfs/linux/libcfs.h     |   18 ---
 .../lustre/include/linux/libcfs/linux/linux-time.h |  103 --------------------
 drivers/staging/lustre/lnet/Kconfig                |    2 
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   32 +++---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |    6 +
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |   17 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |   15 +--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   87 ++++++++---------
 drivers/staging/lustre/lnet/libcfs/debug.c         |    2 
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |   12 +-
 drivers/staging/lustre/lnet/lnet/lib-move.c        |   14 +--
 drivers/staging/lustre/lnet/lnet/net_fault.c       |   40 ++++----
 drivers/staging/lustre/lnet/lnet/peer.c            |    2 
 drivers/staging/lustre/lnet/lnet/router.c          |   17 ++-
 drivers/staging/lustre/lnet/lnet/router_proc.c     |   13 +--
 drivers/staging/lustre/lnet/selftest/conrpc.c      |   14 +--
 drivers/staging/lustre/lnet/selftest/console.c     |    4 -
 drivers/staging/lustre/lnet/selftest/framework.c   |    2 
 drivers/staging/lustre/lnet/selftest/timer.c       |    4 -
 drivers/staging/lustre/lustre/include/cl_object.h  |   10 +-
 drivers/staging/lustre/lustre/include/lu_object.h  |    6 +
 drivers/staging/lustre/lustre/include/lustre_dlm.h |   13 ---
 .../staging/lustre/lustre/include/lustre_export.h  |    7 -
 drivers/staging/lustre/lustre/include/lustre_net.h |    7 +
 drivers/staging/lustre/lustre/include/obd_class.h  |   10 +-
 .../staging/lustre/lustre/include/obd_support.h    |   18 ---
 drivers/staging/lustre/lustre/ldlm/ldlm_flock.c    |   11 --
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   22 +---
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    5 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   66 ++-----------
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   25 ++---
 .../staging/lustre/lustre/llite/llite_internal.h   |    2 
 drivers/staging/lustre/lustre/llite/llite_lib.c    |    4 -
 drivers/staging/lustre/lustre/llite/llite_nfs.c    |    2 
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +-
 drivers/staging/lustre/lustre/llite/statahead.c    |    4 -
 drivers/staging/lustre/lustre/llite/vvp_internal.h |    8 +-
 drivers/staging/lustre/lustre/lmv/lmv_internal.h   |    2 
 drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    2 
 .../staging/lustre/lustre/lov/lov_cl_internal.h    |   18 ++-
 drivers/staging/lustre/lustre/lov/lov_internal.h   |    2 
 drivers/staging/lustre/lustre/lov/lov_obd.c        |    2 
 drivers/staging/lustre/lustre/lov/lov_request.c    |    4 -
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 
 drivers/staging/lustre/lustre/obdclass/cl_io.c     |    1 
 drivers/staging/lustre/lustre/obdclass/cl_object.c |    1 
 drivers/staging/lustre/lustre/obdclass/genops.c    |    2 
 .../lustre/lustre/obdclass/lprocfs_status.c        |   12 +-
 drivers/staging/lustre/lustre/obdclass/lu_object.c |    8 +-
 .../staging/lustre/lustre/obdclass/obd_config.c    |    2 
 .../staging/lustre/lustre/obdecho/echo_client.c    |    2 
 drivers/staging/lustre/lustre/osc/osc_cache.c      |    2 
 .../staging/lustre/lustre/osc/osc_cl_internal.h    |   10 +-
 drivers/staging/lustre/lustre/osc/osc_internal.h   |    2 
 drivers/staging/lustre/lustre/osc/osc_io.c         |    2 
 drivers/staging/lustre/lustre/osc/osc_object.c     |   11 +-
 drivers/staging/lustre/lustre/osc/osc_page.c       |    4 -
 drivers/staging/lustre/lustre/osc/osc_request.c    |    6 +
 drivers/staging/lustre/lustre/ptlrpc/client.c      |    4 -
 drivers/staging/lustre/lustre/ptlrpc/import.c      |   10 +-
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |   23 ++--
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    6 +
 include/linux/kernel.h                             |   16 +++
 66 files changed, 284 insertions(+), 606 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h

--
Signature

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [PATCH 03/17] staging: lustre: LNET excludes USERIO
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

LNET_MINOR and USERIO_MINOR are the same value, so
they cannot both be used in the same kernel.
Until this is resolved, don't allow them to be built
together.  This saves automatic testing from noticing this
known problem.

Reported-by: kernel test robot <fengguang.wu@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lnet/Kconfig |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/Kconfig b/drivers/staging/lustre/lnet/Kconfig
index ad049e6f24e4..fe4b24acf075 100644
--- a/drivers/staging/lustre/lnet/Kconfig
+++ b/drivers/staging/lustre/lnet/Kconfig
@@ -1,6 +1,6 @@
 config LNET
 	tristate "Lustre networking subsystem (LNet)"
-	depends on INET
+	depends on INET && !USERIO
 	help
 	  The Lustre network layer, also known as LNet, is a networking abstaction
 	  level API that was initially created to allow Lustre Filesystem to utilize

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 17/17] staging: lustre: remove cruft from libcfs/linux/libcfs.h
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

These defines are unused or nearly unused, and do not
help at all.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |    2 --
 .../lustre/include/linux/libcfs/linux/libcfs.h     |   17 -----------------
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |    2 +-
 3 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h
index 4702956805a6..d6e4f47b5daf 100644
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
@@ -43,8 +43,6 @@
 /*
  * Plus, platform-specific constant
  *
- * CFS_CURPROC_COMM_MAX,
- *
  * and opaque scalar type
  *
  * kernel_cap_t
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index c39c34d74382..0dbd01617865 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -81,8 +81,6 @@
 #include <stdarg.h>
 #include "linux-cpu.h"
 
-#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
-
 #if !defined(__x86_64__)
 # ifdef __ia64__
 #  define CDEBUG_STACK() (THREAD_SIZE -				 \
@@ -114,19 +112,4 @@ do {								    \
 #define CDEBUG_STACK() (0L)
 #endif /* __x86_64__ */
 
-#define __current_nesting_level() (0)
-
-/**
- * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
- *
- * Implementation is in linux-curproc.c
- */
-#define CFS_CURPROC_COMM_MAX (sizeof((struct task_struct *)0)->comm)
-
-#include <linux/capability.h>
-
-#ifndef WITH_WATCHDOG
-#define WITH_WATCHDOG
-#endif
-
 #endif /* _LINUX_LIBCFS_H */
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 129430e74d00..514e1845740e 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -328,7 +328,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 		goto console;
 	}
 
-	depth = __current_nesting_level();
+	depth = 0;
 	known_size = strlen(file) + 1 + depth;
 	if (msgdata->msg_fn)
 		known_size += strlen(msgdata->msg_fn) + 1;

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 16/17] staging: lustre: discard linux-time.h
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

Very little is left in linux-time.h.
Move CFS_TICK to libcfs.h discard the test.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |    5 ++
 .../lustre/include/linux/libcfs/linux/libcfs.h     |    1 
 .../lustre/include/linux/libcfs/linux/linux-time.h |   66 --------------------
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    2 -
 4 files changed, 6 insertions(+), 68 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 3d3fa52858e5..f183f31da387 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -52,6 +52,11 @@
 
 #define LOWEST_BIT_SET(x)       ((x) & ~((x) - 1))
 
+/*
+ * One jiffy
+ */
+#define CFS_TICK		(1UL)
+
 /*
  * Lustre Error Checksum: calculates checksum
  * of Hex number by XORing each bit.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index 30e333af8d0d..c39c34d74382 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -80,7 +80,6 @@
 #include <linux/uaccess.h>
 #include <stdarg.h>
 #include "linux-cpu.h"
-#include "linux-time.h"
 
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
 
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
deleted file mode 100644
index ecdebccf2b44..000000000000
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/linux/linux-time.h
- *
- * Implementation of portable time API for Linux (kernel and user-level).
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#ifndef __LIBCFS_LINUX_LINUX_TIME_H__
-#define __LIBCFS_LINUX_LINUX_TIME_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
-#endif
-
-#define ONE_BILLION ((u_int64_t)1000000000)
-#define ONE_MILLION 1000000
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/time.h>
-#include <asm/div64.h>
-
-/*
- * post 2.5 kernels.
- */
-
-#include <linux/jiffies.h>
-
-/*
- * One jiffy
- */
-#define CFS_TICK		(1UL)
-
-#define CFS_DURATION_T	  "%ld"
-
-#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 3f17c673d1b8..89eef8ec7df4 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -251,7 +251,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 		 * we will SKIP the next ping at next_ping, and the
 		 * ping will get sent 2 timeouts from now!  Beware.
 		 */
-		CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
+		CDEBUG(D_INFO, "next wakeup in %ld (%ld)\n",
 		       time_to_next_wake,
 		       this_ping + PING_INTERVAL * HZ);
 	} while (time_to_next_wake <= 0);

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 15/17] staging: lustre: discard cfs_time_before_64()
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

cfs_time_before_64 is the same as time_before64()
similarly cfs_time_beforeq_64() matsches time_before_eq64()
So just use the standard interfaces.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 .../lustre/include/linux/libcfs/linux/linux-time.h |   14 --------------
 drivers/staging/lustre/lustre/include/obd_class.h  |    4 ++--
 drivers/staging/lustre/lustre/ptlrpc/import.c      |    4 ++--
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 9a353c6cb85a..ecdebccf2b44 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -56,20 +56,6 @@
 
 #include <linux/jiffies.h>
 
-/*
- * Generic kernel stuff
- */
-
-static inline int cfs_time_before_64(u64 t1, u64 t2)
-{
-	return (__s64)t2 - (__s64)t1 > 0;
-}
-
-static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
-{
-	return (__s64)t2 - (__s64)t1 >= 0;
-}
-
 /*
  * One jiffy
  */
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 7cfc3c8d100c..176b63e2c9a7 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -932,7 +932,7 @@ static inline int obd_statfs_async(struct obd_export *exp,
 
 	CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n",
 	       obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age);
-	if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+	if (time_before64(obd->obd_osfs_age, max_age)) {
 		rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
 	} else {
 		CDEBUG(D_SUPER,
@@ -992,7 +992,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
 
 	CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n",
 	       obd->obd_osfs_age, max_age);
-	if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+	if (time_before64(obd->obd_osfs_age, max_age)) {
 		rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
 		if (rc == 0) {
 			spin_lock(&obd->obd_osfs_lock);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index dd4fd54128dd..537a9e2ed467 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -463,7 +463,7 @@ static int import_select_connection(struct obd_import *imp)
 		 * the last successful attempt, go with this one
 		 */
 		if ((conn->oic_last_attempt == 0) ||
-		    cfs_time_beforeq_64(conn->oic_last_attempt,
+		    time_before_eq64(conn->oic_last_attempt,
 					imp->imp_last_success_conn)) {
 			imp_conn = conn;
 			tried_all = 0;
@@ -476,7 +476,7 @@ static int import_select_connection(struct obd_import *imp)
 		 */
 		if (!imp_conn)
 			imp_conn = conn;
-		else if (cfs_time_before_64(conn->oic_last_attempt,
+		else if (time_before64(conn->oic_last_attempt,
 					    imp_conn->oic_last_attempt))
 			imp_conn = conn;
 	}

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

This wrapper is only used once, so open-code it as max().

This allows us to remove the libcfs_time.h include file.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |    1 
 .../lustre/include/linux/libcfs/libcfs_time.h      |   50 --------------------
 .../lustre/include/linux/libcfs/linux/linux-time.h |    2 -
 drivers/staging/lustre/lustre/ptlrpc/import.c      |    4 +-
 4 files changed, 3 insertions(+), 54 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 3b751c436b3d..3d3fa52858e5 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -43,7 +43,6 @@
 #include <linux/libcfs/libcfs_private.h>
 #include <linux/libcfs/libcfs_cpu.h>
 #include <linux/libcfs/libcfs_prim.h>
-#include <linux/libcfs/libcfs_time.h>
 #include <linux/libcfs/libcfs_string.h>
 #include <linux/libcfs/libcfs_hash.h>
 #include <linux/libcfs/libcfs_fail.h>
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
deleted file mode 100644
index 172a8872e3f3..000000000000
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfs_time.h
- *
- * Time functions.
- *
- */
-
-#ifndef __LIBCFS_TIME_H__
-#define __LIBCFS_TIME_H__
-/*
- * return valid time-out based on user supplied one. Currently we only check
- * that time-out is not shorted than allowed.
- */
-static inline long cfs_timeout_cap(long timeout)
-{
-	if (timeout < CFS_TICK)
-		timeout = CFS_TICK;
-	return timeout;
-}
-
-#endif
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ff3aae2f1231..ecb2126a9e6f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
 /*
  * One jiffy
  */
-#define CFS_TICK		(1)
+#define CFS_TICK		(1UL)
 
 #define CFS_DURATION_T	  "%ld"
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index 4a9d1f189d01..dd4fd54128dd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
 	}
 
 	if (ptlrpc_import_in_recovery(imp)) {
-		long timeout;
+		unsigned long timeout;
 
 		if (AT_OFF) {
 			if (imp->imp_server_timeout)
@@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
 
 		if (wait_event_idle_timeout(imp->imp_recovery_waitq,
 					    !ptlrpc_import_in_recovery(imp),
-					    cfs_timeout_cap(timeout)) == 0)
+					    max(timeout, CFS_TICK)) == 0)
 			l_wait_event_abortable(
 				imp->imp_recovery_waitq,
 				!ptlrpc_import_in_recovery(imp));

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 14/17] staging: lustre: discard cfs_duration_sec()
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

cfs_duration_sec() simply divides by HZ.
It is mostly used to report durations in debug messages.
Remove and just use X/HZ.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 .../lustre/include/linux/libcfs/linux/linux-time.h |    5 -----
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    2 +-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    5 ++---
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |    4 ++--
 drivers/staging/lustre/lnet/libcfs/debug.c         |    2 +-
 drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
 drivers/staging/lustre/lnet/lnet/router_proc.c     |    6 +++---
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    2 +-
 9 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ecb2126a9e6f..9a353c6cb85a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -60,11 +60,6 @@
  * Generic kernel stuff
  */
 
-static inline long cfs_duration_sec(long d)
-{
-	return d / msecs_to_jiffies(MSEC_PER_SEC);
-}
-
 static inline int cfs_time_before_64(u64 t1, u64 t2)
 {
 	return (__s64)t2 - (__s64)t1 > 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index d0ce37d72571..959e119384df 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1068,7 +1068,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,
 
 	CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
 	       libcfs_nid2str(nid), peer,
-	       last_alive ? cfs_duration_sec(now - last_alive) : -1);
+	       last_alive ? (now - last_alive) / HZ : -1);
 }
 
 static void kiblnd_free_pages(struct kib_pages *p)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 563ff5c972bf..b4a182d87ae7 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3144,7 +3144,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs)
 		if (time_after_eq(jiffies, tx->tx_deadline)) {
 			CERROR("Timed out tx: %s, %lu seconds\n",
 			       kiblnd_queue2str(conn, txs),
-			       cfs_duration_sec(jiffies - tx->tx_deadline));
+			       (jiffies - tx->tx_deadline) / HZ);
 			return 1;
 		}
 	}
@@ -3206,8 +3206,7 @@ kiblnd_check_conns(int idx)
 			if (timedout) {
 				CERROR("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n",
 				       libcfs_nid2str(peer->ibp_nid),
-				       cfs_duration_sec(jiffies -
-							peer->ibp_last_alive),
+				       (jiffies - peer->ibp_last_alive) / HZ,
 				       conn->ibc_credits,
 				       conn->ibc_outstanding_credits,
 				       conn->ibc_reserved_credits);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 16c1ab0b0bd9..79b98cdd0f9d 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
 		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
 		       &conn->ksnc_ipaddr, conn->ksnc_port,
 		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
-		       cfs_duration_sec(jiffies - last_rcv));
+		       (jiffies - last_rcv) / HZ);
 		lnet_finalize(conn->ksnc_peer->ksnp_ni,
 			      conn->ksnc_cookie, -EIO);
 		break;
@@ -1870,7 +1870,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
 
 	CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago, connect %d\n",
 	       libcfs_nid2str(nid), peer,
-	       last_alive ? cfs_duration_sec(now - last_alive) : -1,
+	       last_alive ? (now - last_alive) / HZ : -1,
 	       connect);
 
 	if (!connect)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 8ead1e02e854..14450fd5957a 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -751,7 +751,7 @@ ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
 			       &route->ksnr_ipaddr,
 			       route->ksnr_connected,
 			       route->ksnr_retry_interval,
-			       cfs_duration_sec(route->ksnr_timeout - now));
+			       (route->ksnr_timeout - now) / HZ);
 			continue;
 		}
 
@@ -2439,7 +2439,7 @@ ksocknal_check_peer_timeouts(int idx)
 
 		CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n",
 		       n, libcfs_nid2str(peer->ksnp_id.nid), tx_stale,
-		       cfs_duration_sec(jiffies - deadline),
+		       (jiffies - deadline) / HZ,
 		       resid, conn->ksnc_sock->sk->sk_wmem_queued);
 
 		ksocknal_close_conn_and_siblings(conn, -ETIMEDOUT);
diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c
index 1371224a8cb9..5862f0730dd0 100644
--- a/drivers/staging/lustre/lnet/libcfs/debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/debug.c
@@ -126,7 +126,7 @@ static int param_get_delay(char *buffer, const struct kernel_param *kp)
 {
 	unsigned int d = *(unsigned int *)kp->arg;
 
-	return sprintf(buffer, "%u", (unsigned int)cfs_duration_sec(d * 100));
+	return sprintf(buffer, "%u", (unsigned int)(d * 100) / HZ);
 }
 
 unsigned int libcfs_console_max_delay;
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index 8baf35d56ca7..6267d5e4bbd6 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -1752,7 +1752,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
 		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
 		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
 		      libcfs_nid2str(nid), alive ? "up" : "down",
-		      cfs_duration_sec(when - now));
+		      (when - now) / HZ);
 		return -EINVAL;
 	}
 
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index e4172311be68..015dccbc4a58 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -331,7 +331,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 			int alive_cnt = peer->lp_alive_count;
 			int alive = peer->lp_alive;
 			int pingsent = !peer->lp_ping_notsent;
-			int last_ping = cfs_duration_sec(now - peer->lp_ping_timestamp);
+			int last_ping = (now - peer->lp_ping_timestamp) / HZ;
 			int down_ni = 0;
 			struct lnet_route *rtr;
 
@@ -363,7 +363,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 					      nrefs, nrtrrefs, alive_cnt,
 					      alive ? "up" : "down", last_ping,
 					      pingsent,
-					      cfs_duration_sec(deadline - now),
+					      (deadline - now) / HZ,
 					      down_ni, libcfs_nid2str(nid));
 			LASSERT(tmpstr + tmpsiz - s > 0);
 		}
@@ -512,7 +512,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
 				long delta;
 
 				delta = now - peer->lp_last_alive;
-				lastalive = cfs_duration_sec(delta);
+				lastalive = (delta) / HZ;
 
 				/* No need to mess up peers contents with
 				 * arbitrarily long integers - it suffices to
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 187095022fb1..f573de9cf45d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1181,7 +1181,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 
 	slv = ldlm_pool_get_slv(pl);
 	lvf = ldlm_pool_get_lvf(pl);
-	la = cfs_duration_sec(cur - lock->l_last_used);
+	la = (cur - lock->l_last_used) / HZ;
 	lv = lvf * la * unused;
 
 	/* Inform pool about current CLV to see it via debugfs. */

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

This function simply multiplies by HZ and adds jiffies.
This is simple enough to be opencoded, and doing so
makes the code easier to read.

Same for cfs_time_shift_64()

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 .../lustre/include/linux/libcfs/libcfs_time.h      |    5 ----
 .../lustre/include/linux/libcfs/linux/linux-time.h |    5 ----
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   12 +++++----
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    4 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   12 +++++----
 drivers/staging/lustre/lnet/lnet/net_fault.c       |   26 ++++++++++----------
 drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c    |    4 ++-
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +++++----
 drivers/staging/lustre/lustre/llite/statahead.c    |    2 +-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    2 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c        |    2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 +-
 .../lustre/lustre/obdclass/lprocfs_status.c        |   12 +++++----
 .../staging/lustre/lustre/obdclass/obd_config.c    |    2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +-
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    6 ++---
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    2 +-
 21 files changed, 56 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 7b41a129f041..0ebbde4ec8e8 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -50,11 +50,6 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
 	return time_before_eq(t2, t1);
 }
 
-static inline unsigned long cfs_time_shift(int seconds)
-{
-	return jiffies + seconds * HZ;
-}
-
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index b3a80531bd71..ff3aae2f1231 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -65,11 +65,6 @@ static inline long cfs_duration_sec(long d)
 	return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-static inline u64 cfs_time_shift_64(int seconds)
-{
-	return get_jiffies_64() + (u64)seconds * HZ;
-}
-
 static inline int cfs_time_before_64(u64 t1, u64 t2)
 {
 	return (__s64)t2 - (__s64)t1 > 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 7df07f39b849..276bf486f64b 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1446,7 +1446,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps,
 	if (rc)
 		goto out_fpo;
 
-	fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+	fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
 	fpo->fpo_owner = fps;
 	*pp_fpo = fpo;
 
@@ -1619,7 +1619,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
 	spin_lock(&fps->fps_lock);
 	version = fps->fps_version;
 	list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
-		fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+		fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
 		fpo->fpo_map_count++;
 
 		if (fpo->fpo_is_fmr) {
@@ -1743,7 +1743,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
 		fps->fps_version++;
 		list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
 	} else {
-		fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
+		fps->fps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
 	}
 	spin_unlock(&fps->fps_lock);
 
@@ -1764,7 +1764,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, struct kib_pool *pool, int
 
 	memset(pool, 0, sizeof(*pool));
 	INIT_LIST_HEAD(&pool->po_free_list);
-	pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+	pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
 	pool->po_owner    = ps;
 	pool->po_size     = size;
 }
@@ -1899,7 +1899,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
 			continue;
 
 		pool->po_allocated++;
-		pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+		pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
 		node = pool->po_free_list.next;
 		list_del(node);
 
@@ -1947,7 +1947,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
 	if (!rc) {
 		list_add_tail(&pool->po_list, &ps->ps_pool_list);
 	} else {
-		ps->ps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
+		ps->ps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
 		CERROR("Can't allocate new %s pool because out of memory\n",
 		       ps->ps_name);
 	}
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index c1c3277f4c1f..f9761d8f2e3e 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3700,13 +3700,13 @@ kiblnd_failover_thread(void *arg)
 			LASSERT(dev->ibd_failover);
 			dev->ibd_failover = 0;
 			if (rc >= 0) { /* Device is OK or failover succeed */
-				dev->ibd_next_failover = cfs_time_shift(3);
+				dev->ibd_next_failover = jiffies + 3 * HZ;
 				continue;
 			}
 
 			/* failed to failover, retry later */
 			dev->ibd_next_failover =
-				cfs_time_shift(min(dev->ibd_failed_failover, 10));
+				jiffies + min(dev->ibd_failed_failover, 10) * HZ;
 			if (kiblnd_dev_can_failover(dev)) {
 				list_add_tail(&dev->ibd_fail_list,
 					      &kiblnd_data.kib_failed_devs);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 4546618c1c12..16c1ab0b0bd9 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1287,7 +1287,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
 	conn->ksnc_tx_last_post = jiffies;
 	/* Set the deadline for the outgoing HELLO to drain */
 	conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
-	conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+	conn->ksnc_tx_deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 	mb();   /* order with adding to peer's conn list */
 
 	list_add(&conn->ksnc_list, &peer->ksnp_conns);
@@ -1852,7 +1852,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
 			if (bufnob < conn->ksnc_tx_bufnob) {
 				/* something got ACKed */
 				conn->ksnc_tx_deadline =
-					cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+					jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 				peer->ksnp_last_alive = now;
 				conn->ksnc_tx_bufnob = bufnob;
 			}
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 5b34c7c030ad..1ace54c9b133 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -221,7 +221,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 			 * something got ACKed
 			 */
 			conn->ksnc_tx_deadline =
-				cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+				jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 			conn->ksnc_peer->ksnp_last_alive = jiffies;
 			conn->ksnc_tx_bufnob = bufnob;
 			mb();
@@ -269,7 +269,7 @@ ksocknal_recv_iter(struct ksock_conn *conn)
 
 	conn->ksnc_peer->ksnp_last_alive = jiffies;
 	conn->ksnc_rx_deadline =
-		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 	mb();		       /* order with setting rx_started */
 	conn->ksnc_rx_started = 1;
 
@@ -405,7 +405,7 @@ ksocknal_check_zc_req(struct ksock_tx *tx)
 
 	/* ZC_REQ is going to be pinned to the peer */
 	tx->tx_deadline =
-		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 
 	LASSERT(!tx->tx_msg.ksm_zc_cookies[0]);
 
@@ -677,7 +677,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
 	if (list_empty(&conn->ksnc_tx_queue) && !bufnob) {
 		/* First packet starts the timeout */
 		conn->ksnc_tx_deadline =
-			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 		if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
 			conn->ksnc_peer->ksnp_last_alive = jiffies;
 		conn->ksnc_tx_bufnob = 0;
@@ -858,7 +858,7 @@ ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
 	    ksocknal_find_connecting_route_locked(peer)) {
 		/* the message is going to be pinned to the peer */
 		tx->tx_deadline =
-			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 
 		/* Queue the message until a connection is established */
 		list_add_tail(&tx->tx_list, &peer->ksnp_tx_queue);
@@ -2308,7 +2308,7 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
 	 * retry 10 secs later, so we wouldn't put pressure
 	 * on this peer if we failed to send keepalive this time
 	 */
-	peer->ksnp_send_keepalive = cfs_time_shift(10);
+	peer->ksnp_send_keepalive = jiffies + 10 * HZ;
 
 	conn = ksocknal_find_conn_locked(peer, NULL, 1);
 	if (conn) {
diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
index 3928e9a74d6f..05d7b754815a 100644
--- a/drivers/staging/lustre/lnet/lnet/net_fault.c
+++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
@@ -169,9 +169,9 @@ lnet_drop_rule_add(struct lnet_fault_attr *attr)
 
 	rule->dr_attr = *attr;
 	if (attr->u.drop.da_interval) {
-		rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
-		rule->dr_drop_time = cfs_time_shift(
-			prandom_u32_max(attr->u.drop.da_interval));
+		rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
+		rule->dr_drop_time = jiffies +
+			prandom_u32_max(attr->u.drop.da_interval) * HZ;
 	} else {
 		rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
 	}
@@ -279,9 +279,9 @@ lnet_drop_rule_reset(void)
 		if (attr->u.drop.da_rate) {
 			rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
 		} else {
-			rule->dr_drop_time = cfs_time_shift(
-				prandom_u32_max(attr->u.drop.da_interval));
-			rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
+			rule->dr_drop_time = jiffies +
+				prandom_u32_max(attr->u.drop.da_interval) * HZ;
+			rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
 		}
 		spin_unlock(&rule->dr_lock);
 	}
@@ -513,7 +513,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
 
 	list_add_tail(&msg->msg_list, &rule->dl_msg_list);
 	msg->msg_delay_send = round_timeout(
-			cfs_time_shift(attr->u.delay.la_latency));
+			jiffies + attr->u.delay.la_latency * HZ);
 	if (rule->dl_msg_send == -1) {
 		rule->dl_msg_send = msg->msg_delay_send;
 		mod_timer(&rule->dl_timer, rule->dl_msg_send);
@@ -767,9 +767,9 @@ lnet_delay_rule_add(struct lnet_fault_attr *attr)
 
 	rule->dl_attr = *attr;
 	if (attr->u.delay.la_interval) {
-		rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
-		rule->dl_delay_time = cfs_time_shift(
-			prandom_u32_max(attr->u.delay.la_interval));
+		rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
+		rule->dl_delay_time = jiffies + 
+			prandom_u32_max(attr->u.delay.la_interval) * HZ;
 	} else {
 		rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
 	}
@@ -920,9 +920,9 @@ lnet_delay_rule_reset(void)
 			rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
 		} else {
 			rule->dl_delay_time =
-				cfs_time_shift(prandom_u32_max(
-						       attr->u.delay.la_interval));
-			rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
+				jiffies + prandom_u32_max(
+					attr->u.delay.la_interval) * HZ;
+			rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
 		}
 		spin_unlock(&rule->dl_lock);
 	}
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index 4595a7ad4336..c72d4f4454ec 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -1026,7 +1026,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
 
 		if (!rtr->lp_ping_deadline) {
 			rtr->lp_ping_deadline =
-				cfs_time_shift(router_ping_timeout);
+				jiffies + router_ping_timeout * HZ;
 		}
 
 		lnet_net_unlock(rtr->lp_cpt);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 6eb42f16040d..647e85b16c02 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -118,7 +118,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
 				 lock->l_last_activity));
 		if (cfs_time_after(jiffies, next_dump)) {
 			last_dump = next_dump;
-			next_dump = cfs_time_shift(300);
+			next_dump = jiffies + 300 * HZ;
 			ldlm_namespace_dump(D_DLMTRACE,
 					    ldlm_lock_to_ns(lock));
 			if (last_dump == 0)
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index ccd0c082e39b..6c615b6e9bdc 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1323,7 +1323,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
 				 ldlm_res_hash_dump,
 				 (void *)(unsigned long)level, 0);
 	spin_lock(&ns->ns_lock);
-	ns->ns_next_dump = cfs_time_shift(10);
+	ns->ns_next_dump = jiffies + 10 * HZ;
 	spin_unlock(&ns->ns_lock);
 }
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index e7500c53fafc..60dbe888e336 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -257,7 +257,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 	 * available
 	 */
 	err = obd_statfs(NULL, sbi->ll_md_exp, osfs,
-			 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			 get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			 OBD_STATFS_FOR_MDT0);
 	if (err)
 		goto out_md_fid;
@@ -1675,7 +1675,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
 
 	/* Some amount of caching on the client is allowed */
 	rc = ll_statfs_internal(sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				0);
 	if (rc)
 		return rc;
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 644bea2f9d37..164fe4d6b6b8 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -53,7 +53,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%u\n", osfs.os_bsize);
@@ -71,7 +71,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -96,7 +96,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -121,7 +121,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -146,7 +146,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%llu\n", osfs.os_files);
@@ -164,7 +164,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%llu\n", osfs.os_ffree);
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index 6f996acf6aa8..b4a6ee6c83f3 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -523,7 +523,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
 	 *    affect the performance.
 	 */
 	if (lli->lli_glimpse_time != 0 &&
-	    time_before(cfs_time_shift(-1), lli->lli_glimpse_time)) {
+	    time_before(jiffies - 1 * HZ, lli->lli_glimpse_time)) {
 		up_write(&lli->lli_glimpse_sem);
 		lli->lli_agl_index = 0;
 		iput(inode);
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index e8a9b9902c37..7be931039e3c 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -876,7 +876,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
 			return -EFAULT;
 
 		rc = obd_statfs(NULL, tgt->ltd_exp, &stat_buf,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				0);
 		if (rc)
 			return rc;
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index ec70c12e5b40..355e87ecc62d 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -1063,7 +1063,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
 		/* got statfs data */
 		rc = obd_statfs(NULL, lov->lov_tgts[index]->ltd_exp, &stat_buf,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				flags);
 		if (rc)
 			return rc;
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 3b1c8e5a3053..266fa90cb03d 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -2104,7 +2104,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 		}
 
 		rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				0);
 		if (rc != 0)
 			goto out;
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 2ed350527398..eb6396add78d 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -407,7 +407,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%u\n", osfs.os_bsize);
@@ -423,7 +423,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -446,7 +446,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -469,7 +469,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -492,7 +492,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%llu\n", osfs.os_files);
@@ -508,7 +508,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%llu\n", osfs.os_ffree);
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 277576b586db..eab03766236f 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -269,7 +269,7 @@ static int class_attach(struct lustre_cfg *lcfg)
 	/* obd->obd_osfs_age must be set to a value in the distant
 	 * past to guarantee a fresh statfs is fetched on mount.
 	 */
-	obd->obd_osfs_age = cfs_time_shift_64(-1000);
+	obd->obd_osfs_age = get_jiffies_64() - 1000 * HZ;
 
 	/* XXX belongs in setup not attach  */
 	init_rwsem(&obd->obd_observer_link_sem);
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 9966fc7af789..04d801f11ace 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -617,7 +617,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
 void osc_update_next_shrink(struct client_obd *cli)
 {
 	cli->cl_next_shrink_grant =
-		cfs_time_shift(cli->cl_grant_shrink_interval);
+		jiffies + cli->cl_grant_shrink_interval * HZ;
 	CDEBUG(D_CACHE, "next time %ld to shrink grant\n",
 	       cli->cl_next_shrink_grant);
 }
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index e836591c5936..7057b4447035 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -108,7 +108,7 @@ static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
 				  at_get(&imp->imp_at.iat_net_latency));
 		time = min(time, dtime);
 	}
-	imp->imp_next_ping = cfs_time_shift(time);
+	imp->imp_next_ping = jiffies + time * HZ;
 }
 
 static inline int imp_is_deactive(struct obd_import *imp)
@@ -120,9 +120,9 @@ static inline int imp_is_deactive(struct obd_import *imp)
 static inline int ptlrpc_next_reconnect(struct obd_import *imp)
 {
 	if (imp->imp_server_timeout)
-		return cfs_time_shift(obd_timeout / 2);
+		return jiffies + obd_timeout / 2 * HZ;
 	else
-		return cfs_time_shift(obd_timeout);
+		return jiffies + obd_timeout * HZ;
 }
 
 static long pinger_check_timeout(unsigned long time)
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index e71046db28e5..4265e8d00ca5 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -922,7 +922,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
 	if (next <= 0) {
 		ptlrpc_at_timer(&svcpt->scp_at_timer);
 	} else {
-		mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
+		mod_timer(&svcpt->scp_at_timer, jiffies + next * HZ);
 		CDEBUG(D_INFO, "armed %s at %+ds\n",
 		       svcpt->scp_service->srv_name, next);
 	}

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 12/17] staging: lustre: libcfs: discard cfs_time_after()
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

cfs_time_after() behaves exactly like time_after()
similarly cfs_time_aftereq() matches time_after_eq()

so discard the cfs versions.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 .../lustre/include/linux/libcfs/libcfs_time.h      |   14 ---------
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    4 +--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |    6 ++--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    2 +
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   32 ++++++++++----------
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |    8 +++--
 drivers/staging/lustre/lnet/lnet/lib-move.c        |    4 +--
 drivers/staging/lustre/lnet/lnet/net_fault.c       |    8 +++--
 drivers/staging/lustre/lnet/lnet/router.c          |    6 ++--
 drivers/staging/lustre/lnet/selftest/conrpc.c      |    4 +--
 drivers/staging/lustre/lnet/selftest/timer.c       |    2 +
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    4 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    4 +--
 drivers/staging/lustre/lustre/osc/osc_object.c     |    2 +
 drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    6 ++--
 16 files changed, 47 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 0ebbde4ec8e8..172a8872e3f3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -36,20 +36,6 @@
 
 #ifndef __LIBCFS_TIME_H__
 #define __LIBCFS_TIME_H__
-/*
- * generic time manipulation functions.
- */
-
-static inline int cfs_time_after(unsigned long t1, unsigned long t2)
-{
-	return time_before(t2, t1);
-}
-
-static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
-{
-	return time_before_eq(t2, t1);
-}
-
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 276bf486f64b..d0ce37d72571 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1522,7 +1522,7 @@ static int kiblnd_fmr_pool_is_idle(struct kib_fmr_pool *fpo, unsigned long now)
 		return 0;
 	if (fpo->fpo_failed)
 		return 1;
-	return cfs_time_aftereq(now, fpo->fpo_deadline);
+	return time_after_eq(now, fpo->fpo_deadline);
 }
 
 static int
@@ -1850,7 +1850,7 @@ static int kiblnd_pool_is_idle(struct kib_pool *pool, unsigned long now)
 		return 0;
 	if (pool->po_failed)
 		return 1;
-	return cfs_time_aftereq(now, pool->po_deadline);
+	return time_after_eq(now, pool->po_deadline);
 }
 
 void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index b18911d09e9a..ca6e09de0872 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -754,9 +754,9 @@ static inline int
 kiblnd_send_keepalive(struct kib_conn *conn)
 {
 	return (*kiblnd_tunables.kib_keepalive > 0) &&
-		cfs_time_after(jiffies, conn->ibc_last_send +
-			       msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
-						MSEC_PER_SEC));
+		time_after(jiffies, conn->ibc_last_send +
+			   msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
+					    MSEC_PER_SEC));
 }
 
 static inline int
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index f9761d8f2e3e..563ff5c972bf 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3141,7 +3141,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs)
 			LASSERT(tx->tx_waiting || tx->tx_sending);
 		}
 
-		if (cfs_time_aftereq(jiffies, tx->tx_deadline)) {
+		if (time_after_eq(jiffies, tx->tx_deadline)) {
 			CERROR("Timed out tx: %s, %lu seconds\n",
 			       kiblnd_queue2str(conn, txs),
 			       cfs_duration_sec(jiffies - tx->tx_deadline));
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 1ace54c9b133..8ead1e02e854 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -481,7 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 		LASSERT(conn->ksnc_tx_scheduled);
 		list_add_tail(&conn->ksnc_tx_list,
 			      &ksocknal_data.ksnd_enomem_conns);
-		if (!cfs_time_aftereq(jiffies + SOCKNAL_ENOMEM_RETRY,
+		if (!time_after_eq(jiffies + SOCKNAL_ENOMEM_RETRY,
 				   ksocknal_data.ksnd_reaper_waketime))
 			wake_up(&ksocknal_data.ksnd_reaper_waitq);
 
@@ -590,7 +590,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
 		case SOCKNAL_MATCH_YES: /* typed connection */
 			if (!typed || tnob > nob ||
 			    (tnob == nob && *ksocknal_tunables.ksnd_round_robin &&
-			     cfs_time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
+			     time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
 				typed = c;
 				tnob  = nob;
 			}
@@ -599,7 +599,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
 		case SOCKNAL_MATCH_MAY: /* fallback connection */
 			if (!fallback || fnob > nob ||
 			    (fnob == nob && *ksocknal_tunables.ksnd_round_robin &&
-			     cfs_time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
+			     time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
 				fallback = c;
 				fnob = nob;
 			}
@@ -745,7 +745,7 @@ ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
 			continue;
 
 		if (!(!route->ksnr_retry_interval || /* first attempt */
-		      cfs_time_aftereq(now, route->ksnr_timeout))) {
+		      time_after_eq(now, route->ksnr_timeout))) {
 			CDEBUG(D_NET,
 			       "Too soon to retry route %pI4h (cnted %d, interval %ld, %ld secs later)\n",
 			       &route->ksnr_ipaddr,
@@ -1823,7 +1823,7 @@ ksocknal_connect(struct ksock_route *route)
 
 		write_unlock_bh(&ksocknal_data.ksnd_global_lock);
 
-		if (cfs_time_aftereq(jiffies, deadline)) {
+		if (time_after_eq(jiffies, deadline)) {
 			rc = -ETIMEDOUT;
 			lnet_connect_console_error(rc, peer->ksnp_id.nid,
 						   route->ksnr_ipaddr,
@@ -2052,7 +2052,7 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
 	list_for_each_entry(route, &ksocknal_data.ksnd_connd_routes,
 			    ksnr_connd_list) {
 		if (!route->ksnr_retry_interval ||
-		    cfs_time_aftereq(now, route->ksnr_timeout))
+		    time_after_eq(now, route->ksnr_timeout))
 			return route;
 
 		if (*timeout_p == MAX_SCHEDULE_TIMEOUT ||
@@ -2224,8 +2224,8 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
 		}
 
 		if (conn->ksnc_rx_started &&
-		    cfs_time_aftereq(jiffies,
-				     conn->ksnc_rx_deadline)) {
+		    time_after_eq(jiffies,
+				  conn->ksnc_rx_deadline)) {
 			/* Timed out incomplete incoming message */
 			ksocknal_conn_addref(conn);
 			CNETERR("Timeout receiving from %s (%pI4h:%d), state %d wanted %zd left %d\n",
@@ -2240,8 +2240,8 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
 
 		if ((!list_empty(&conn->ksnc_tx_queue) ||
 		     conn->ksnc_sock->sk->sk_wmem_queued) &&
-		    cfs_time_aftereq(jiffies,
-				     conn->ksnc_tx_deadline)) {
+		    time_after_eq(jiffies,
+				  conn->ksnc_tx_deadline)) {
 			/*
 			 * Timed out messages queued for sending or
 			 * buffered in the socket's send buffer
@@ -2268,8 +2268,8 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer)
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
 	list_for_each_entry_safe(tx, tmp, &peer->ksnp_tx_queue, tx_list) {
-		if (!cfs_time_aftereq(jiffies,
-				      tx->tx_deadline))
+		if (!time_after_eq(jiffies,
+				   tx->tx_deadline))
 			break;
 
 		list_del(&tx->tx_list);
@@ -2395,8 +2395,8 @@ ksocknal_check_peer_timeouts(int idx)
 			tx = list_entry(peer->ksnp_tx_queue.next,
 					struct ksock_tx, tx_list);
 
-			if (cfs_time_aftereq(jiffies,
-					     tx->tx_deadline)) {
+			if (time_after_eq(jiffies,
+					  tx->tx_deadline)) {
 				ksocknal_peer_addref(peer);
 				read_unlock(&ksocknal_data.ksnd_global_lock);
 
@@ -2413,8 +2413,8 @@ ksocknal_check_peer_timeouts(int idx)
 		tx_stale = NULL;
 		spin_lock(&peer->ksnp_lock);
 		list_for_each_entry(tx, &peer->ksnp_zc_req_list, tx_zc_list) {
-			if (!cfs_time_aftereq(jiffies,
-					      tx->tx_deadline))
+			if (!time_after_eq(jiffies,
+					   tx->tx_deadline))
 				break;
 			/* ignore the TX if connection is being closed */
 			if (tx->tx_conn->ksnc_closing)
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 2aeae0331ee0..129430e74d00 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -431,7 +431,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 	if (cdls) {
 		if (libcfs_console_ratelimit &&
 		    cdls->cdls_next &&		/* not first time ever */
-		    !cfs_time_after(jiffies, cdls->cdls_next)) {
+		    !time_after(jiffies, cdls->cdls_next)) {
 			/* skipping a console message */
 			cdls->cdls_count++;
 			if (tcd)
@@ -439,9 +439,9 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 			return 1;
 		}
 
-		if (cfs_time_after(jiffies,
-				   cdls->cdls_next + libcfs_console_max_delay +
-				   10 * HZ)) {
+		if (time_after(jiffies,
+			       cdls->cdls_next + libcfs_console_max_delay +
+			       10 * HZ)) {
 			/* last timeout was a long time ago */
 			cdls->cdls_delay /= libcfs_console_backoff * 4;
 		} else {
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index 5574d2148c9d..60464135161b 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -520,11 +520,11 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
 	 * ignore the initial assumed death (see lnet_peers_start_down()).
 	 */
 	if (!lp->lp_alive && lp->lp_alive_count > 0 &&
-	    cfs_time_aftereq(lp->lp_timestamp, lp->lp_last_alive))
+	    time_after_eq(lp->lp_timestamp, lp->lp_last_alive))
 		return 0;
 
 	deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout * HZ;
-	alive = cfs_time_after(deadline, now);
+	alive = time_after(deadline, now);
 
 	/* Update obsolete lp_alive except for routers assumed to be dead
 	 * initially, because router checker would update aliveness in this
diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
index 05d7b754815a..0066394b0bb0 100644
--- a/drivers/staging/lustre/lnet/lnet/net_fault.c
+++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
@@ -309,9 +309,9 @@ drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
 		unsigned long now = jiffies;
 
 		rule->dr_stat.fs_count++;
-		drop = cfs_time_aftereq(now, rule->dr_drop_time);
+		drop = time_after_eq(now, rule->dr_drop_time);
 		if (drop) {
-			if (cfs_time_after(now, rule->dr_time_base))
+			if (time_after(now, rule->dr_time_base))
 				rule->dr_time_base = now;
 
 			rule->dr_drop_time = rule->dr_time_base +
@@ -475,9 +475,9 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
 		unsigned long now = jiffies;
 
 		rule->dl_stat.fs_count++;
-		delay = cfs_time_aftereq(now, rule->dl_delay_time);
+		delay = time_after_eq(now, rule->dl_delay_time);
 		if (delay) {
-			if (cfs_time_after(now, rule->dl_time_base))
+			if (time_after(now, rule->dl_time_base))
 				rule->dl_time_base = now;
 
 			rule->dl_delay_time = rule->dl_time_base +
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index c72d4f4454ec..8baf35d56ca7 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -982,7 +982,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
 	lnet_peer_addref_locked(rtr);
 
 	if (rtr->lp_ping_deadline && /* ping timed out? */
-	    cfs_time_after(now, rtr->lp_ping_deadline))
+	    time_after(now, rtr->lp_ping_deadline))
 		lnet_notify_locked(rtr, 1, 0, now);
 
 	/* Run any outstanding notifications */
@@ -1010,7 +1010,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
 	       rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
 
 	if (secs && !rtr->lp_ping_notsent &&
-	    cfs_time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
+	    time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
 		int rc;
 		struct lnet_process_id id;
 		struct lnet_handle_md mdh;
@@ -1748,7 +1748,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
 	}
 
 	/* can't do predictions... */
-	if (cfs_time_after(when, now)) {
+	if (time_after(when, now)) {
 		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
 		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
 		      libcfs_nid2str(nid), alive ? "up" : "down",
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index ea4944b9108b..8c237758c3eb 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -315,7 +315,7 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
 			continue;
 
 		nd = crpc->crp_node;
-		if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
+		if (time_after(nd->nd_stamp, crpc->crp_stamp))
 			continue;
 
 		nd->nd_stamp = crpc->crp_stamp;
@@ -404,7 +404,7 @@ lstcon_rpc_get_reply(struct lstcon_rpc *crpc, struct srpc_msg **msgpp)
 		crpc->crp_unpacked = 1;
 	}
 
-	if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
+	if (time_after(nd->nd_stamp, crpc->crp_stamp))
 		return 0;
 
 	nd->nd_stamp = crpc->crp_stamp;
diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
index 1f9d5487e2f5..582f252b3e12 100644
--- a/drivers/staging/lustre/lnet/selftest/timer.c
+++ b/drivers/staging/lustre/lnet/selftest/timer.c
@@ -155,7 +155,7 @@ stt_check_timers(unsigned long *last)
 
 	spin_lock(&stt_data.stt_lock);
 
-	while (cfs_time_aftereq(this_slot, *last)) {
+	while (time_after_eq(this_slot, *last)) {
 		expired += stt_expire_list(STTIMER_SLOT(this_slot), now);
 		this_slot = this_slot - STTIMER_SLOTTIME;
 	}
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index 150e78c9eb68..942d34f7a44c 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -325,8 +325,8 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
 	lock_res_and_lock(lock);
 	if (lock->l_granted_mode == LCK_PW &&
 	    !lock->l_readers && !lock->l_writers &&
-	    cfs_time_after(jiffies,
-			   lock->l_last_used + 10 * HZ)) {
+	    time_after(jiffies,
+		       lock->l_last_used + 10 * HZ)) {
 		unlock_res_and_lock(lock);
 		if (ldlm_bl_to_thread_lock(ns, NULL, lock))
 			ldlm_handle_bl_callback(ns, NULL, lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 647e85b16c02..187095022fb1 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -116,7 +116,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
 			   (s64)lock->l_last_activity,
 			   (s64)(ktime_get_real_seconds() -
 				 lock->l_last_activity));
-		if (cfs_time_after(jiffies, next_dump)) {
+		if (time_after(jiffies, next_dump)) {
 			last_dump = next_dump;
 			next_dump = jiffies + 300 * HZ;
 			ldlm_namespace_dump(D_DLMTRACE,
@@ -1176,7 +1176,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 	 * Despite of the LV, It doesn't make sense to keep the lock which
 	 * is unused for ns_max_age time.
 	 */
-	if (cfs_time_after(jiffies, lock->l_last_used + ns->ns_max_age))
+	if (time_after(jiffies, lock->l_last_used + ns->ns_max_age))
 		return LDLM_POLICY_CANCEL_LOCK;
 
 	slv = ldlm_pool_get_slv(pl);
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index 154d1721636e..84240181c7ea 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -328,7 +328,7 @@ int osc_object_is_contended(struct osc_object *obj)
 	 * ll_file_is_contended.
 	 */
 	retry_time = obj->oo_contention_time + osc_contention_time * HZ;
-	if (cfs_time_after(cur_time, retry_time)) {
+	if (time_after(cur_time, retry_time)) {
 		osc_object_clear_contended(obj);
 		return 0;
 	}
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 04d801f11ace..0038e555e905 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -748,7 +748,7 @@ static int osc_should_shrink_grant(struct client_obd *client)
 	     OBD_CONNECT_GRANT_SHRINK) == 0)
 		return 0;
 
-	if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) {
+	if (time_after_eq(time, next_shrink - 5 * CFS_TICK)) {
 		/* Get the current RPC size directly, instead of going via:
 		 * cli_brw_size(obd->u.cli.cl_import->imp_obd->obd_self_export)
 		 * Keep comment here so that it can be found by searching.
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 7057b4447035..3f17c673d1b8 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -180,7 +180,7 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp,
 
 	imp->imp_force_verify = 0;
 
-	if (cfs_time_aftereq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
+	if (time_after_eq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
 	    !force) {
 		spin_unlock(&imp->imp_lock);
 		return;
@@ -236,8 +236,8 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 			ptlrpc_pinger_process_import(imp, this_ping);
 			/* obd_timeout might have changed */
 			if (imp->imp_pingable && imp->imp_next_ping &&
-			    cfs_time_after(imp->imp_next_ping,
-					   this_ping + PING_INTERVAL * HZ))
+			    time_after(imp->imp_next_ping,
+				       this_ping + PING_INTERVAL * HZ))
 				ptlrpc_update_next_ping(imp, 0);
 		}
 		mutex_unlock(&pinger_mutex);

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 09/17] staging: lustre: cfs_time_current() -> jiffies.
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

Discard cfs_time_current() and cfs_time_current64()
and use jiffies and get_jiffies_64() like the rest of the kernel.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 .../lustre/include/linux/libcfs/libcfs_time.h      |    2 -
 .../lustre/include/linux/libcfs/linux/linux-time.h |    9 ----
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   14 +++---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    8 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    9 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   44 ++++++++++----------
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |    6 +--
 drivers/staging/lustre/lnet/lnet/lib-move.c        |    4 +-
 drivers/staging/lustre/lnet/lnet/net_fault.c       |    6 +--
 drivers/staging/lustre/lnet/lnet/peer.c            |    2 -
 drivers/staging/lustre/lnet/lnet/router.c          |    6 +--
 drivers/staging/lustre/lnet/lnet/router_proc.c     |    4 +-
 drivers/staging/lustre/lnet/selftest/conrpc.c      |    6 +--
 drivers/staging/lustre/lnet/selftest/console.c     |    4 +-
 drivers/staging/lustre/lnet/selftest/framework.c   |    2 -
 drivers/staging/lustre/lustre/include/lustre_net.h |    2 -
 drivers/staging/lustre/lustre/include/obd_class.h  |    6 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |    2 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    2 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   10 ++---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 -
 .../staging/lustre/lustre/llite/llite_internal.h   |    2 -
 drivers/staging/lustre/lustre/llite/statahead.c    |    2 -
 drivers/staging/lustre/lustre/lov/lov_request.c    |    4 +-
 drivers/staging/lustre/lustre/osc/osc_cache.c      |    2 -
 drivers/staging/lustre/lustre/osc/osc_object.c     |    4 +-
 drivers/staging/lustre/lustre/osc/osc_page.c       |    4 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    |    2 -
 drivers/staging/lustre/lustre/ptlrpc/client.c      |    4 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c      |    2 -
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    4 +-
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    4 +-
 32 files changed, 88 insertions(+), 96 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index c4f25be78268..df7a3f13f3b3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -62,7 +62,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
 
 static inline unsigned long cfs_time_shift(int seconds)
 {
-	return cfs_time_add(cfs_time_current(), seconds * HZ);
+	return cfs_time_add(jiffies, seconds * HZ);
 }
 
 /*
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 805cb326af86..ba115e8c820f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -60,18 +60,11 @@
  * Generic kernel stuff
  */
 
-static inline unsigned long cfs_time_current(void)
-{
-	return jiffies;
-}
-
 static inline long cfs_duration_sec(long d)
 {
 	return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-#define cfs_time_current_64 get_jiffies_64
-
 static inline u64 cfs_time_add_64(u64 t, u64 d)
 {
 	return t + d;
@@ -79,7 +72,7 @@ static inline u64 cfs_time_add_64(u64 t, u64 d)
 
 static inline u64 cfs_time_shift_64(int seconds)
 {
-	return cfs_time_add_64(cfs_time_current_64(),
+	return cfs_time_add_64(get_jiffies_64(),
 			       seconds * HZ);
 }
 
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 7ae2955c4db6..7df07f39b849 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1043,7 +1043,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,
 			 unsigned long *when)
 {
 	unsigned long last_alive = 0;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	rwlock_t *glock = &kiblnd_data.kib_global_lock;
 	struct kib_peer *peer;
 	unsigned long flags;
@@ -1552,7 +1552,7 @@ void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int status)
 	LIST_HEAD(zombies);
 	struct kib_fmr_pool *fpo = fmr->fmr_pool;
 	struct kib_fmr_poolset *fps;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	struct kib_fmr_pool *tmp;
 	int rc;
 
@@ -1726,7 +1726,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
 		goto again;
 	}
 
-	if (time_before(cfs_time_current(), fps->fps_next_retry)) {
+	if (time_before(jiffies, fps->fps_next_retry)) {
 		/* someone failed recently */
 		spin_unlock(&fps->fps_lock);
 		return -EAGAIN;
@@ -1858,7 +1858,7 @@ void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
 	LIST_HEAD(zombies);
 	struct kib_poolset *ps = pool->po_owner;
 	struct kib_pool *tmp;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 
 	spin_lock(&ps->ps_lock);
 
@@ -1927,7 +1927,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
 		goto again;
 	}
 
-	if (time_before(cfs_time_current(), ps->ps_next_retry)) {
+	if (time_before(jiffies, ps->ps_next_retry)) {
 		/* someone failed recently */
 		spin_unlock(&ps->ps_lock);
 		return NULL;
@@ -1937,10 +1937,10 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
 	spin_unlock(&ps->ps_lock);
 
 	CDEBUG(D_NET, "%s pool exhausted, allocate new pool\n", ps->ps_name);
-	time_before = cfs_time_current();
+	time_before = jiffies;
 	rc = ps->ps_pool_create(ps, ps->ps_pool_size, &pool);
 	CDEBUG(D_NET, "ps_pool_create took %lu HZ to complete",
-	       cfs_time_current() - time_before);
+	       jiffies - time_before);
 
 	spin_lock(&ps->ps_lock);
 	ps->ps_increasing = 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 6690a6cd4e34..c1c3277f4c1f 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1853,8 +1853,8 @@ kiblnd_thread_fini(void)
 static void
 kiblnd_peer_alive(struct kib_peer *peer)
 {
-	/* This is racy, but everyone's only writing cfs_time_current() */
-	peer->ibp_last_alive = cfs_time_current();
+	/* This is racy, but everyone's only writing jiffies */
+	peer->ibp_last_alive = jiffies;
 	mb();
 }
 
@@ -3206,7 +3206,7 @@ kiblnd_check_conns(int idx)
 			if (timedout) {
 				CERROR("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n",
 				       libcfs_nid2str(peer->ibp_nid),
-				       cfs_duration_sec(cfs_time_current() -
+				       cfs_duration_sec(jiffies -
 							peer->ibp_last_alive),
 				       conn->ibc_credits,
 				       conn->ibc_outstanding_credits,
@@ -3681,7 +3681,7 @@ kiblnd_failover_thread(void *arg)
 
 		list_for_each_entry(dev, &kiblnd_data.kib_failed_devs,
 				    ibd_fail_list) {
-			if (time_before(cfs_time_current(),
+			if (time_before(jiffies,
 					dev->ibd_next_failover))
 				continue;
 			do_failover = 1;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 7086678e1c3e..0efde0009a15 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1276,7 +1276,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
 	}
 
 	conn->ksnc_peer = peer;		 /* conn takes my ref on peer */
-	peer->ksnp_last_alive = cfs_time_current();
+	peer->ksnp_last_alive = jiffies;
 	peer->ksnp_send_keepalive = 0;
 	peer->ksnp_error = 0;
 
@@ -1284,7 +1284,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
 	sched->kss_nconns++;
 	conn->ksnc_scheduler = sched;
 
-	conn->ksnc_tx_last_post = cfs_time_current();
+	conn->ksnc_tx_last_post = jiffies;
 	/* Set the deadline for the outgoing HELLO to drain */
 	conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
 	conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
@@ -1682,8 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
 		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
 		       &conn->ksnc_ipaddr, conn->ksnc_port,
 		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
-		       cfs_duration_sec(cfs_time_sub(cfs_time_current(),
-						     last_rcv)));
+		       cfs_duration_sec(cfs_time_sub(jiffies, last_rcv)));
 		lnet_finalize(conn->ksnc_peer->ksnp_ni,
 			      conn->ksnc_cookie, -EIO);
 		break;
@@ -1832,7 +1831,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
 {
 	int connect = 1;
 	unsigned long last_alive = 0;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	struct ksock_peer *peer = NULL;
 	rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
 	struct lnet_process_id id = {
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 036fecbcede8..f97da4540b51 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -222,7 +222,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 			 */
 			conn->ksnc_tx_deadline =
 				cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
-			conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
+			conn->ksnc_peer->ksnp_last_alive = jiffies;
 			conn->ksnc_tx_bufnob = bufnob;
 			mb();
 		}
@@ -267,7 +267,7 @@ ksocknal_recv_iter(struct ksock_conn *conn)
 	/* received something... */
 	nob = rc;
 
-	conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
+	conn->ksnc_peer->ksnp_last_alive = jiffies;
 	conn->ksnc_rx_deadline =
 		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
 	mb();		       /* order with setting rx_started */
@@ -481,7 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 		LASSERT(conn->ksnc_tx_scheduled);
 		list_add_tail(&conn->ksnc_tx_list,
 			      &ksocknal_data.ksnd_enomem_conns);
-		if (!cfs_time_aftereq(cfs_time_add(cfs_time_current(),
+		if (!cfs_time_aftereq(cfs_time_add(jiffies,
 						   SOCKNAL_ENOMEM_RETRY),
 				   ksocknal_data.ksnd_reaper_waketime))
 			wake_up(&ksocknal_data.ksnd_reaper_waitq);
@@ -612,7 +612,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
 	conn = (typed) ? typed : fallback;
 
 	if (conn)
-		conn->ksnc_tx_last_post = cfs_time_current();
+		conn->ksnc_tx_last_post = jiffies;
 
 	return conn;
 }
@@ -680,7 +680,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
 		conn->ksnc_tx_deadline =
 			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
 		if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
-			conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
+			conn->ksnc_peer->ksnp_last_alive = jiffies;
 		conn->ksnc_tx_bufnob = 0;
 		mb(); /* order with adding to tx_queue */
 	}
@@ -728,7 +728,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
 struct ksock_route *
 ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
 {
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	struct list_head *tmp;
 	struct ksock_route *route;
 
@@ -1777,7 +1777,7 @@ ksocknal_connect(struct ksock_route *route)
 	int retry_later = 0;
 	int rc = 0;
 
-	deadline = cfs_time_add(cfs_time_current(),
+	deadline = cfs_time_add(jiffies,
 				*ksocknal_tunables.ksnd_timeout * HZ);
 
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -1825,7 +1825,7 @@ ksocknal_connect(struct ksock_route *route)
 
 		write_unlock_bh(&ksocknal_data.ksnd_global_lock);
 
-		if (cfs_time_aftereq(cfs_time_current(), deadline)) {
+		if (cfs_time_aftereq(jiffies, deadline)) {
 			rc = -ETIMEDOUT;
 			lnet_connect_console_error(rc, peer->ksnp_id.nid,
 						   route->ksnr_ipaddr,
@@ -1877,7 +1877,7 @@ ksocknal_connect(struct ksock_route *route)
 			 */
 			route->ksnr_retry_interval =
 				*ksocknal_tunables.ksnd_min_reconnectms * HZ / 1000;
-			route->ksnr_timeout = cfs_time_add(cfs_time_current(),
+			route->ksnr_timeout = cfs_time_add(jiffies,
 							   route->ksnr_retry_interval);
 		}
 
@@ -1903,7 +1903,7 @@ ksocknal_connect(struct ksock_route *route)
 		    (long)*ksocknal_tunables.ksnd_max_reconnectms * HZ / 1000);
 
 	LASSERT(route->ksnr_retry_interval);
-	route->ksnr_timeout = cfs_time_add(cfs_time_current(),
+	route->ksnr_timeout = cfs_time_add(jiffies,
 					   route->ksnr_retry_interval);
 
 	if (!list_empty(&peer->ksnp_tx_queue) &&
@@ -2050,7 +2050,7 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
 	struct ksock_route *route;
 	unsigned long now;
 
-	now = cfs_time_current();
+	now = jiffies;
 
 	/* connd_routes can contain both pending and ordinary routes */
 	list_for_each_entry(route, &ksocknal_data.ksnd_connd_routes,
@@ -2228,7 +2228,7 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
 		}
 
 		if (conn->ksnc_rx_started &&
-		    cfs_time_aftereq(cfs_time_current(),
+		    cfs_time_aftereq(jiffies,
 				     conn->ksnc_rx_deadline)) {
 			/* Timed out incomplete incoming message */
 			ksocknal_conn_addref(conn);
@@ -2244,7 +2244,7 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
 
 		if ((!list_empty(&conn->ksnc_tx_queue) ||
 		     conn->ksnc_sock->sk->sk_wmem_queued) &&
-		    cfs_time_aftereq(cfs_time_current(),
+		    cfs_time_aftereq(jiffies,
 				     conn->ksnc_tx_deadline)) {
 			/*
 			 * Timed out messages queued for sending or
@@ -2272,7 +2272,7 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer)
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
 	list_for_each_entry_safe(tx, tmp, &peer->ksnp_tx_queue, tx_list) {
-		if (!cfs_time_aftereq(cfs_time_current(),
+		if (!cfs_time_aftereq(jiffies,
 				      tx->tx_deadline))
 			break;
 
@@ -2301,12 +2301,12 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
 		return 0;
 
 	if (*ksocknal_tunables.ksnd_keepalive <= 0 ||
-	    time_before(cfs_time_current(),
+	    time_before(jiffies,
 			cfs_time_add(peer->ksnp_last_alive,
 				     *ksocknal_tunables.ksnd_keepalive * HZ)))
 		return 0;
 
-	if (time_before(cfs_time_current(), peer->ksnp_send_keepalive))
+	if (time_before(jiffies, peer->ksnp_send_keepalive))
 		return 0;
 
 	/*
@@ -2400,7 +2400,7 @@ ksocknal_check_peer_timeouts(int idx)
 			tx = list_entry(peer->ksnp_tx_queue.next,
 					struct ksock_tx, tx_list);
 
-			if (cfs_time_aftereq(cfs_time_current(),
+			if (cfs_time_aftereq(jiffies,
 					     tx->tx_deadline)) {
 				ksocknal_peer_addref(peer);
 				read_unlock(&ksocknal_data.ksnd_global_lock);
@@ -2418,7 +2418,7 @@ ksocknal_check_peer_timeouts(int idx)
 		tx_stale = NULL;
 		spin_lock(&peer->ksnp_lock);
 		list_for_each_entry(tx, &peer->ksnp_zc_req_list, tx_zc_list) {
-			if (!cfs_time_aftereq(cfs_time_current(),
+			if (!cfs_time_aftereq(jiffies,
 					      tx->tx_deadline))
 				break;
 			/* ignore the TX if connection is being closed */
@@ -2444,7 +2444,7 @@ ksocknal_check_peer_timeouts(int idx)
 
 		CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n",
 		       n, libcfs_nid2str(peer->ksnp_id.nid), tx_stale,
-		       cfs_duration_sec(cfs_time_current() - deadline),
+		       cfs_duration_sec(jiffies - deadline),
 		       resid, conn->ksnc_sock->sk->sk_wmem_queued);
 
 		ksocknal_close_conn_and_siblings(conn, -ETIMEDOUT);
@@ -2466,7 +2466,7 @@ ksocknal_reaper(void *arg)
 	long timeout;
 	int i;
 	int peer_index = 0;
-	unsigned long deadline = cfs_time_current();
+	unsigned long deadline = jiffies;
 
 	INIT_LIST_HEAD(&enomem_conns);
 	init_waitqueue_entry(&wait, current);
@@ -2532,7 +2532,7 @@ ksocknal_reaper(void *arg)
 
 		/* careful with the jiffy wrap... */
 		while ((timeout = cfs_time_sub(deadline,
-					       cfs_time_current())) <= 0) {
+					       jiffies)) <= 0) {
 			const int n = 4;
 			const int p = 1;
 			int chunk = ksocknal_data.ksnd_peer_hash_size;
@@ -2569,7 +2569,7 @@ ksocknal_reaper(void *arg)
 			timeout = SOCKNAL_ENOMEM_RETRY;
 		}
 		ksocknal_data.ksnd_reaper_waketime =
-			cfs_time_add(cfs_time_current(), timeout);
+			cfs_time_add(jiffies, timeout);
 
 		set_current_state(TASK_INTERRUPTIBLE);
 		add_wait_queue(&ksocknal_data.ksnd_reaper_waitq, &wait);
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 4affca750bc5..2aeae0331ee0 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -431,7 +431,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 	if (cdls) {
 		if (libcfs_console_ratelimit &&
 		    cdls->cdls_next &&		/* not first time ever */
-		    !cfs_time_after(cfs_time_current(), cdls->cdls_next)) {
+		    !cfs_time_after(jiffies, cdls->cdls_next)) {
 			/* skipping a console message */
 			cdls->cdls_count++;
 			if (tcd)
@@ -439,7 +439,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 			return 1;
 		}
 
-		if (cfs_time_after(cfs_time_current(),
+		if (cfs_time_after(jiffies,
 				   cdls->cdls_next + libcfs_console_max_delay +
 				   10 * HZ)) {
 			/* last timeout was a long time ago */
@@ -454,7 +454,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 			cdls->cdls_delay = libcfs_console_max_delay;
 
 		/* ensure cdls_next is never zero after it's been seen */
-		cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1;
+		cdls->cdls_next = (jiffies + cdls->cdls_delay) | 1;
 	}
 
 	if (tcd) {
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index ed43b3f4b114..289ed876bd81 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -501,7 +501,7 @@ lnet_ni_query_locked(struct lnet_ni *ni, struct lnet_peer *lp)
 	ni->ni_lnd->lnd_query(ni, lp->lp_nid, &last_alive);
 	lnet_net_lock(lp->lp_cpt);
 
-	lp->lp_last_query = cfs_time_current();
+	lp->lp_last_query = jiffies;
 
 	if (last_alive) /* NI has updated timestamp */
 		lp->lp_last_alive = last_alive;
@@ -545,7 +545,7 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
 static int
 lnet_peer_alive_locked(struct lnet_peer *lp)
 {
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 
 	if (!lnet_peer_aliveness_enabled(lp))
 		return -ENODEV;
diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
index a63b7941d435..3928e9a74d6f 100644
--- a/drivers/staging/lustre/lnet/lnet/net_fault.c
+++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
@@ -306,7 +306,7 @@ drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
 	/* match this rule, check drop rate now */
 	spin_lock(&rule->dr_lock);
 	if (rule->dr_drop_time) { /* time based drop */
-		unsigned long now = cfs_time_current();
+		unsigned long now = jiffies;
 
 		rule->dr_stat.fs_count++;
 		drop = cfs_time_aftereq(now, rule->dr_drop_time);
@@ -472,7 +472,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
 	/* match this rule, check delay rate now */
 	spin_lock(&rule->dl_lock);
 	if (rule->dl_delay_time) { /* time based delay */
-		unsigned long now = cfs_time_current();
+		unsigned long now = jiffies;
 
 		rule->dl_stat.fs_count++;
 		delay = cfs_time_aftereq(now, rule->dl_delay_time);
@@ -562,7 +562,7 @@ delayed_msg_check(struct lnet_delay_rule *rule, bool all,
 {
 	struct lnet_msg *msg;
 	struct lnet_msg *tmp;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 
 	if (!all && rule->dl_msg_send > now)
 		return;
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index 3d4caa609c83..58294149f7b2 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -315,7 +315,7 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
 	lp->lp_alive_count = 0;
 	lp->lp_timestamp = 0;
 	lp->lp_alive = !lnet_peers_start_down(); /* 1 bit!! */
-	lp->lp_last_alive = cfs_time_current(); /* assumes alive */
+	lp->lp_last_alive = jiffies; /* assumes alive */
 	lp->lp_last_query = 0; /* haven't asked NI yet */
 	lp->lp_ping_timestamp = 0;
 	lp->lp_ping_feats = LNET_PING_FEAT_INVAL;
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index a3c3f4959f46..ac9b392a0afa 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -765,7 +765,7 @@ lnet_router_checker_event(struct lnet_event *event)
 	 * we ping alive routers to try to detect router death before
 	 * apps get burned).
 	 */
-	lnet_notify_locked(lp, 1, !event->status, cfs_time_current());
+	lnet_notify_locked(lp, 1, !event->status, jiffies);
 
 	/*
 	 * The router checker will wake up very shortly and do the
@@ -976,7 +976,7 @@ static void
 lnet_ping_router_locked(struct lnet_peer *rtr)
 {
 	struct lnet_rc_data *rcd = NULL;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	int secs;
 
 	lnet_peer_addref_locked(rtr);
@@ -1730,7 +1730,7 @@ int
 lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
 {
 	struct lnet_peer *lp = NULL;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	int cpt = lnet_cpt_of_nid(nid);
 
 	LASSERT(!in_interrupt());
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 1a71ffebc889..315d067540c0 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -324,7 +324,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 
 		if (peer) {
 			lnet_nid_t nid = peer->lp_nid;
-			unsigned long now = cfs_time_current();
+			unsigned long now = jiffies;
 			unsigned long deadline = peer->lp_ping_deadline;
 			int nrefs = peer->lp_refcount;
 			int nrtrrefs = peer->lp_rtr_refcount;
@@ -509,7 +509,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
 				aliveness = peer->lp_alive ? "up" : "down";
 
 			if (lnet_peer_aliveness_enabled(peer)) {
-				unsigned long now = cfs_time_current();
+				unsigned long now = jiffies;
 				long delta;
 
 				delta = cfs_time_sub(now, peer->lp_last_alive);
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index 6dcc966b293b..68e06e06857d 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -75,7 +75,7 @@ lstcon_rpc_done(struct srpc_client_rpc *rpc)
 		/* not aborted */
 		LASSERT(!crpc->crp_status);
 
-		crpc->crp_stamp = cfs_time_current();
+		crpc->crp_stamp = jiffies;
 		crpc->crp_status = rpc->crpc_status;
 	}
 
@@ -297,14 +297,14 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
 		if (!crpc->crp_posted || /* not posted */
 		    crpc->crp_stamp) {	 /* rpc done or aborted already */
 			if (!crpc->crp_stamp) {
-				crpc->crp_stamp = cfs_time_current();
+				crpc->crp_stamp = jiffies;
 				crpc->crp_status = -EINTR;
 			}
 			spin_unlock(&rpc->crpc_lock);
 			continue;
 		}
 
-		crpc->crp_stamp = cfs_time_current();
+		crpc->crp_stamp = jiffies;
 		crpc->crp_status = error;
 
 		spin_unlock(&rpc->crpc_lock);
diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
index 1acd5cb324b1..1889f1e86473 100644
--- a/drivers/staging/lustre/lnet/selftest/console.c
+++ b/drivers/staging/lustre/lnet/selftest/console.c
@@ -98,7 +98,7 @@ lstcon_node_find(struct lnet_process_id id, struct lstcon_node **ndpp,
 
 	ndl->ndl_node->nd_ref = 1;
 	ndl->ndl_node->nd_id = id;
-	ndl->ndl_node->nd_stamp = cfs_time_current();
+	ndl->ndl_node->nd_stamp = jiffies;
 	ndl->ndl_node->nd_state = LST_NODE_UNKNOWN;
 	ndl->ndl_node->nd_timeout = 0;
 	memset(&ndl->ndl_node->nd_ping, 0, sizeof(struct lstcon_rpc));
@@ -1701,7 +1701,7 @@ lstcon_new_session_id(struct lst_sid *sid)
 
 	LNetGetId(1, &id);
 	sid->ses_nid = id.nid;
-	sid->ses_stamp = cfs_time_current();
+	sid->ses_stamp = jiffies;
 }
 
 int
diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
index 0ca1e3a780ca..045eecd23e0a 100644
--- a/drivers/staging/lustre/lnet/selftest/framework.c
+++ b/drivers/staging/lustre/lnet/selftest/framework.c
@@ -272,7 +272,7 @@ sfw_init_session(struct sfw_session *sn, struct lst_sid sid,
 	sn->sn_id = sid;
 	sn->sn_features = features;
 	sn->sn_timeout = session_timeout;
-	sn->sn_started = cfs_time_current();
+	sn->sn_started = jiffies;
 
 	timer->stt_data = sn;
 	timer->stt_func = sfw_session_expired;
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index d35ae0cda8d2..f4824d8ec741 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -2255,7 +2255,7 @@ static inline int ptlrpc_send_limit_expired(struct ptlrpc_request *req)
 	if (req->rq_delay_limit != 0 &&
 	    time_before(cfs_time_add(req->rq_queued_time,
 				     req->rq_delay_limit * HZ),
-			cfs_time_current())) {
+			jiffies)) {
 		return 1;
 	}
 	return 0;
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index f24dd74ffa09..7cfc3c8d100c 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -913,7 +913,7 @@ static inline int obd_destroy_export(struct obd_export *exp)
 /*
  * @max_age is the oldest time in jiffies that we accept using a cached data.
  * If the cache is older than @max_age we will get a new value from the
- * target.  Use a value of "cfs_time_current() + HZ" to guarantee freshness.
+ * target.  Use a value of "jiffies + HZ" to guarantee freshness.
  */
 static inline int obd_statfs_async(struct obd_export *exp,
 				   struct obd_info *oinfo,
@@ -975,7 +975,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp,
 /*
  * @max_age is the oldest time in jiffies that we accept using a cached data.
  * If the cache is older than @max_age we will get a new value from the
- * target.  Use a value of "cfs_time_current() + HZ" to guarantee freshness.
+ * target.  Use a value of "jiffies + HZ" to guarantee freshness.
  */
 static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
 			     struct obd_statfs *osfs, __u64 max_age,
@@ -997,7 +997,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
 		if (rc == 0) {
 			spin_lock(&obd->obd_osfs_lock);
 			memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
-			obd->obd_osfs_age = cfs_time_current_64();
+			obd->obd_osfs_age = get_jiffies_64();
 			spin_unlock(&obd->obd_osfs_lock);
 		}
 	} else {
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 614caa4a9b0e..22c49cc593e3 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -243,7 +243,7 @@ static void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock)
 {
 	struct ldlm_namespace *ns = ldlm_lock_to_ns(lock);
 
-	lock->l_last_used = cfs_time_current();
+	lock->l_last_used = jiffies;
 	LASSERT(list_empty(&lock->l_lru));
 	LASSERT(lock->l_resource->lr_type != LDLM_FLOCK);
 	list_add_tail(&lock->l_lru, &ns->ns_unused_list);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index c772c68e5a49..ab4dd15c8dd4 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -325,7 +325,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
 	lock_res_and_lock(lock);
 	if (lock->l_granted_mode == LCK_PW &&
 	    !lock->l_readers && !lock->l_writers &&
-	    cfs_time_after(cfs_time_current(),
+	    cfs_time_after(jiffies,
 			   cfs_time_add(lock->l_last_used,
 					10 * HZ))) {
 		unlock_res_and_lock(lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 8e79f5e073ff..0e1b21c1f06d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -116,7 +116,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
 			   (s64)lock->l_last_activity,
 			   (s64)(ktime_get_real_seconds() -
 				 lock->l_last_activity));
-		if (cfs_time_after(cfs_time_current(), next_dump)) {
+		if (cfs_time_after(jiffies, next_dump)) {
 			last_dump = next_dump;
 			next_dump = cfs_time_shift(300);
 			ldlm_namespace_dump(D_DLMTRACE,
@@ -1161,7 +1161,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 						    int unused, int added,
 						    int count)
 {
-	unsigned long cur = cfs_time_current();
+	unsigned long cur = jiffies;
 	struct ldlm_pool *pl = &ns->ns_pool;
 	__u64 slv, lvf, lv;
 	unsigned long la;
@@ -1176,7 +1176,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 	 * Despite of the LV, It doesn't make sense to keep the lock which
 	 * is unused for ns_max_age time.
 	 */
-	if (cfs_time_after(cfs_time_current(),
+	if (cfs_time_after(jiffies,
 			   cfs_time_add(lock->l_last_used, ns->ns_max_age)))
 		return LDLM_POLICY_CANCEL_LOCK;
 
@@ -1233,7 +1233,7 @@ static enum ldlm_policy_res ldlm_cancel_aged_policy(struct ldlm_namespace *ns,
 						    int count)
 {
 	if ((added >= count) &&
-	    time_before(cfs_time_current(),
+	    time_before(jiffies,
 			cfs_time_add(lock->l_last_used, ns->ns_max_age)))
 		return LDLM_POLICY_KEEP_LOCK;
 
@@ -1380,7 +1380,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
 				continue;
 
 			last_use = lock->l_last_used;
-			if (last_use == cfs_time_current())
+			if (last_use == jiffies)
 				continue;
 
 			/* Somebody is already doing CANCEL. No need for this
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 8841a1bb2c0a..ccd0c082e39b 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1316,7 +1316,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
 	CDEBUG(level, "--- Namespace: %s (rc: %d, side: client)\n",
 	       ldlm_ns_name(ns), atomic_read(&ns->ns_bref));
 
-	if (time_before(cfs_time_current(), ns->ns_next_dump))
+	if (time_before(jiffies, ns->ns_next_dump))
 		return;
 
 	cfs_hash_for_each_nolock(ns->ns_rs_hash,
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index d46bcf71b273..6504850e3689 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -1110,7 +1110,7 @@ static inline int ll_glimpse_size(struct inode *inode)
 
 	down_read(&lli->lli_glimpse_sem);
 	rc = cl_glimpse_size(inode);
-	lli->lli_glimpse_time = cfs_time_current();
+	lli->lli_glimpse_time = jiffies;
 	up_read(&lli->lli_glimpse_sem);
 	return rc;
 }
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index 155ce3cf6f60..6f996acf6aa8 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -535,7 +535,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
 
 	cl_agl(inode);
 	lli->lli_agl_index = 0;
-	lli->lli_glimpse_time = cfs_time_current();
+	lli->lli_glimpse_time = jiffies;
 	up_write(&lli->lli_glimpse_sem);
 
 	CDEBUG(D_READA, "Handled (init) async glimpse: inode= "
diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
index 051450d67524..41fc023cc381 100644
--- a/drivers/staging/lustre/lustre/lov/lov_request.c
+++ b/drivers/staging/lustre/lustre/lov/lov_request.c
@@ -160,7 +160,7 @@ static int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,
 
 		spin_lock(&obd->obd_osfs_lock);
 		memcpy(&obd->obd_osfs, osfs, sizeof(*osfs));
-		obd->obd_osfs_age = cfs_time_current_64();
+		obd->obd_osfs_age = get_jiffies_64();
 		spin_unlock(&obd->obd_osfs_lock);
 		return 0;
 	}
@@ -277,7 +277,7 @@ static int cb_statfs_update(void *cookie, int rc)
 	spin_lock(&tgtobd->obd_osfs_lock);
 	memcpy(&tgtobd->obd_osfs, lov_sfs, sizeof(*lov_sfs));
 	if ((oinfo->oi_flags & OBD_STATFS_FROM_CACHE) == 0)
-		tgtobd->obd_osfs_age = cfs_time_current_64();
+		tgtobd->obd_osfs_age = get_jiffies_64();
 	spin_unlock(&tgtobd->obd_osfs_lock);
 
 out_update:
diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
index 459503727ce3..ba4a4bf3b0f1 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -1290,7 +1290,7 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
 
 	result = cl_page_make_ready(env, page, CRT_WRITE);
 	if (result == 0)
-		opg->ops_submit_time = cfs_time_current();
+		opg->ops_submit_time = jiffies;
 	return result;
 }
 
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index 9582d5a642e2..c5dc894a4c1b 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -300,7 +300,7 @@ static int osc_object_fiemap(const struct lu_env *env, struct cl_object *obj,
 
 void osc_object_set_contended(struct osc_object *obj)
 {
-	obj->oo_contention_time = cfs_time_current();
+	obj->oo_contention_time = jiffies;
 	/* mb(); */
 	obj->oo_contended = 1;
 }
@@ -314,7 +314,7 @@ int osc_object_is_contended(struct osc_object *obj)
 {
 	struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
 	int osc_contention_time = dev->od_contention_time;
-	unsigned long cur_time = cfs_time_current();
+	unsigned long cur_time = jiffies;
 	unsigned long retry_time;
 
 	if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index 01a930dbbf64..20c553ef3a5e 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -125,7 +125,7 @@ static inline unsigned long osc_submit_duration(struct osc_page *opg)
 	if (opg->ops_submit_time == 0)
 		return 0;
 
-	return (cfs_time_current() - opg->ops_submit_time);
+	return (jiffies - opg->ops_submit_time);
 }
 
 static int osc_page_print(const struct lu_env *env,
@@ -312,7 +312,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
 		oap->oap_cmd |= OBD_BRW_NOQUOTA;
 	}
 
-	opg->ops_submit_time = cfs_time_current();
+	opg->ops_submit_time = jiffies;
 	osc_page_transfer_get(opg, "transfer\0imm");
 	osc_page_transfer_add(env, opg, crt);
 }
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 1c2bbbf5d864..9966fc7af789 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -741,7 +741,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
 
 static int osc_should_shrink_grant(struct client_obd *client)
 {
-	unsigned long time = cfs_time_current();
+	unsigned long time = jiffies;
 	unsigned long next_shrink = client->cl_next_shrink_grant;
 
 	if ((client->cl_import->imp_connect_data.ocd_connect_flags &
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index ca096fadb9c0..eeb281266413 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -1050,7 +1050,7 @@ void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
 	list_add_tail(&req->rq_set_chain, &set->set_requests);
 	req->rq_set = set;
 	atomic_inc(&set->set_remaining);
-	req->rq_queued_time = cfs_time_current();
+	req->rq_queued_time = jiffies;
 
 	if (req->rq_reqmsg)
 		lustre_msg_set_jobid(req->rq_reqmsg, NULL);
@@ -1081,7 +1081,7 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
 	spin_lock(&set->set_new_req_lock);
 	/* The set takes over the caller's request reference.  */
 	req->rq_set = set;
-	req->rq_queued_time = cfs_time_current();
+	req->rq_queued_time = jiffies;
 	list_add_tail(&req->rq_set_chain, &set->set_new_requests);
 	count = atomic_inc_return(&set->set_new_count);
 	spin_unlock(&set->set_new_req_lock);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index a2c4fc3488b1..4a9d1f189d01 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -508,7 +508,7 @@ static int import_select_connection(struct obd_import *imp)
 		       imp->imp_obd->obd_name, at_get(at));
 	}
 
-	imp_conn->oic_last_attempt = cfs_time_current_64();
+	imp_conn->oic_last_attempt = get_jiffies_64();
 
 	/* switch connection, don't mind if it's same as the current one */
 	ptlrpc_connection_put(imp->imp_connection);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 0775b7a048bb..57c7db47e249 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -142,7 +142,7 @@ static long pinger_check_timeout(unsigned long time)
 	mutex_unlock(&pinger_mutex);
 
 	return cfs_time_sub(cfs_time_add(time, timeout * HZ),
-					 cfs_time_current());
+					 jiffies);
 }
 
 static bool ir_up;
@@ -223,7 +223,7 @@ static DECLARE_DELAYED_WORK(ping_work, ptlrpc_pinger_main);
 
 static void ptlrpc_pinger_main(struct work_struct *ws)
 {
-	unsigned long this_ping = cfs_time_current();
+	unsigned long this_ping = jiffies;
 	long time_to_next_wake;
 	struct timeout_item *item;
 	struct obd_import *imp;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index f37364e00dfe..fc29efbd9914 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -336,7 +336,7 @@ static void ptlrpc_at_timer(struct timer_list *t)
 	svcpt = from_timer(svcpt, t, scp_at_timer);
 
 	svcpt->scp_at_check = 1;
-	svcpt->scp_at_checktime = cfs_time_current();
+	svcpt->scp_at_checktime = jiffies;
 	wake_up(&svcpt->scp_waitq);
 }
 
@@ -1153,7 +1153,7 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
 		spin_unlock(&svcpt->scp_at_lock);
 		return;
 	}
-	delay = cfs_time_sub(cfs_time_current(), svcpt->scp_at_checktime);
+	delay = cfs_time_sub(jiffies, svcpt->scp_at_checktime);
 	svcpt->scp_at_check = 0;
 
 	if (array->paa_count == 0) {

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 10/17] staging: lustre: libcfs: discard cfs_time_add/sub
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

cfs_time_add adds its arguments.
cfs_time_sub subtracts finds the difference.
Discard these and use '+' and '-' directly.

This change highlighted a type error.  The structure field
cr_queued_time was used to store jiffies, but was declared
as time_t (meant for seconds).  So the time is changed to
"unsigned long".

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 .../lustre/include/linux/libcfs/libcfs_time.h      |   12 +---------
 .../lustre/include/linux/libcfs/linux/linux-time.h |    8 +------
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    2 +-
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   23 +++++++-------------
 drivers/staging/lustre/lnet/lnet/lib-move.c        |    6 ++---
 drivers/staging/lustre/lnet/lnet/router.c          |    5 ++--
 drivers/staging/lustre/lnet/lnet/router_proc.c     |    7 +++---
 drivers/staging/lustre/lnet/selftest/conrpc.c      |    4 ++-
 drivers/staging/lustre/lnet/selftest/timer.c       |    2 +-
 drivers/staging/lustre/lustre/include/lustre_net.h |    5 ++--
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    3 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    8 +++----
 drivers/staging/lustre/lustre/osc/osc_object.c     |    3 +--
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    9 +++-----
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    2 +-
 15 files changed, 32 insertions(+), 67 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index df7a3f13f3b3..7b41a129f041 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -40,16 +40,6 @@
  * generic time manipulation functions.
  */
 
-static inline unsigned long cfs_time_add(unsigned long t, long d)
-{
-	return (unsigned long)(t + d);
-}
-
-static inline unsigned long cfs_time_sub(unsigned long t1, unsigned long t2)
-{
-	return (unsigned long)(t1 - t2);
-}
-
 static inline int cfs_time_after(unsigned long t1, unsigned long t2)
 {
 	return time_before(t2, t1);
@@ -62,7 +52,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
 
 static inline unsigned long cfs_time_shift(int seconds)
 {
-	return cfs_time_add(jiffies, seconds * HZ);
+	return jiffies + seconds * HZ;
 }
 
 /*
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ba115e8c820f..b3a80531bd71 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -65,15 +65,9 @@ static inline long cfs_duration_sec(long d)
 	return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-static inline u64 cfs_time_add_64(u64 t, u64 d)
-{
-	return t + d;
-}
-
 static inline u64 cfs_time_shift_64(int seconds)
 {
-	return cfs_time_add_64(get_jiffies_64(),
-			       seconds * HZ);
+	return get_jiffies_64() + (u64)seconds * HZ;
 }
 
 static inline int cfs_time_before_64(u64 t1, u64 t2)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 0efde0009a15..4546618c1c12 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
 		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
 		       &conn->ksnc_ipaddr, conn->ksnc_port,
 		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
-		       cfs_duration_sec(cfs_time_sub(jiffies, last_rcv)));
+		       cfs_duration_sec(jiffies - last_rcv));
 		lnet_finalize(conn->ksnc_peer->ksnp_ni,
 			      conn->ksnc_cookie, -EIO);
 		break;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index f97da4540b51..5b34c7c030ad 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -481,8 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 		LASSERT(conn->ksnc_tx_scheduled);
 		list_add_tail(&conn->ksnc_tx_list,
 			      &ksocknal_data.ksnd_enomem_conns);
-		if (!cfs_time_aftereq(cfs_time_add(jiffies,
-						   SOCKNAL_ENOMEM_RETRY),
+		if (!cfs_time_aftereq(jiffies + SOCKNAL_ENOMEM_RETRY,
 				   ksocknal_data.ksnd_reaper_waketime))
 			wake_up(&ksocknal_data.ksnd_reaper_waitq);
 
@@ -1777,8 +1776,7 @@ ksocknal_connect(struct ksock_route *route)
 	int retry_later = 0;
 	int rc = 0;
 
-	deadline = cfs_time_add(jiffies,
-				*ksocknal_tunables.ksnd_timeout * HZ);
+	deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
@@ -1877,8 +1875,7 @@ ksocknal_connect(struct ksock_route *route)
 			 */
 			route->ksnr_retry_interval =
 				*ksocknal_tunables.ksnd_min_reconnectms * HZ / 1000;
-			route->ksnr_timeout = cfs_time_add(jiffies,
-							   route->ksnr_retry_interval);
+			route->ksnr_timeout = jiffies + route->ksnr_retry_interval;
 		}
 
 		ksocknal_launch_connection_locked(route);
@@ -1903,8 +1900,7 @@ ksocknal_connect(struct ksock_route *route)
 		    (long)*ksocknal_tunables.ksnd_max_reconnectms * HZ / 1000);
 
 	LASSERT(route->ksnr_retry_interval);
-	route->ksnr_timeout = cfs_time_add(jiffies,
-					   route->ksnr_retry_interval);
+	route->ksnr_timeout = jiffies + route->ksnr_retry_interval;
 
 	if (!list_empty(&peer->ksnp_tx_queue) &&
 	    !peer->ksnp_accepting &&
@@ -2302,8 +2298,7 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
 
 	if (*ksocknal_tunables.ksnd_keepalive <= 0 ||
 	    time_before(jiffies,
-			cfs_time_add(peer->ksnp_last_alive,
-				     *ksocknal_tunables.ksnd_keepalive * HZ)))
+			peer->ksnp_last_alive + *ksocknal_tunables.ksnd_keepalive * HZ))
 		return 0;
 
 	if (time_before(jiffies, peer->ksnp_send_keepalive))
@@ -2531,8 +2526,7 @@ ksocknal_reaper(void *arg)
 		}
 
 		/* careful with the jiffy wrap... */
-		while ((timeout = cfs_time_sub(deadline,
-					       jiffies)) <= 0) {
+		while ((timeout = deadline - jiffies) <= 0) {
 			const int n = 4;
 			const int p = 1;
 			int chunk = ksocknal_data.ksnd_peer_hash_size;
@@ -2557,7 +2551,7 @@ ksocknal_reaper(void *arg)
 					     ksocknal_data.ksnd_peer_hash_size;
 			}
 
-			deadline = cfs_time_add(deadline, p * HZ);
+			deadline = deadline + p * HZ;
 		}
 
 		if (nenomem_conns) {
@@ -2568,8 +2562,7 @@ ksocknal_reaper(void *arg)
 			 */
 			timeout = SOCKNAL_ENOMEM_RETRY;
 		}
-		ksocknal_data.ksnd_reaper_waketime =
-			cfs_time_add(jiffies, timeout);
+		ksocknal_data.ksnd_reaper_waketime = jiffies + timeout;
 
 		set_current_state(TASK_INTERRUPTIBLE);
 		add_wait_queue(&ksocknal_data.ksnd_reaper_waitq, &wait);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index 289ed876bd81..5574d2148c9d 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -523,8 +523,7 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
 	    cfs_time_aftereq(lp->lp_timestamp, lp->lp_last_alive))
 		return 0;
 
-	deadline = cfs_time_add(lp->lp_last_alive,
-				lp->lp_ni->ni_peertimeout * HZ);
+	deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout * HZ;
 	alive = cfs_time_after(deadline, now);
 
 	/* Update obsolete lp_alive except for routers assumed to be dead
@@ -561,8 +560,7 @@ lnet_peer_alive_locked(struct lnet_peer *lp)
 		static const int lnet_queryinterval = 1;
 
 		unsigned long next_query =
-			   cfs_time_add(lp->lp_last_query,
-					lnet_queryinterval * HZ);
+			   lp->lp_last_query + lnet_queryinterval * HZ;
 
 		if (time_before(now, next_query)) {
 			if (lp->lp_alive)
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index ac9b392a0afa..4595a7ad4336 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -1010,8 +1010,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
 	       rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
 
 	if (secs && !rtr->lp_ping_notsent &&
-	    cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp,
-					     secs * HZ))) {
+	    cfs_time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
 		int rc;
 		struct lnet_process_id id;
 		struct lnet_handle_md mdh;
@@ -1753,7 +1752,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
 		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
 		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
 		      libcfs_nid2str(nid), alive ? "up" : "down",
-		      cfs_duration_sec(cfs_time_sub(when, now)));
+		      cfs_duration_sec(when - now));
 		return -EINVAL;
 	}
 
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 315d067540c0..e4172311be68 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -331,8 +331,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 			int alive_cnt = peer->lp_alive_count;
 			int alive = peer->lp_alive;
 			int pingsent = !peer->lp_ping_notsent;
-			int last_ping = cfs_duration_sec(cfs_time_sub(now,
-						     peer->lp_ping_timestamp));
+			int last_ping = cfs_duration_sec(now - peer->lp_ping_timestamp);
 			int down_ni = 0;
 			struct lnet_route *rtr;
 
@@ -364,7 +363,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 					      nrefs, nrtrrefs, alive_cnt,
 					      alive ? "up" : "down", last_ping,
 					      pingsent,
-					      cfs_duration_sec(cfs_time_sub(deadline, now)),
+					      cfs_duration_sec(deadline - now),
 					      down_ni, libcfs_nid2str(nid));
 			LASSERT(tmpstr + tmpsiz - s > 0);
 		}
@@ -512,7 +511,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
 				unsigned long now = jiffies;
 				long delta;
 
-				delta = cfs_time_sub(now, peer->lp_last_alive);
+				delta = now - peer->lp_last_alive;
 				lastalive = cfs_duration_sec(delta);
 
 				/* No need to mess up peers contents with
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index 68e06e06857d..ea4944b9108b 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -500,8 +500,8 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
 
 		nd = crpc->crp_node;
 
-		dur = (long)cfs_time_sub(crpc->crp_stamp,
-		      (unsigned long)console_session.ses_id.ses_stamp);
+		dur = (long)(crpc->crp_stamp -
+			     (unsigned long)console_session.ses_id.ses_stamp);
 		jiffies_to_timeval(dur, &tv);
 
 		if (copy_to_user(&ent->rpe_peer, &nd->nd_id,
diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
index 1b2c5fc81358..1f9d5487e2f5 100644
--- a/drivers/staging/lustre/lnet/selftest/timer.c
+++ b/drivers/staging/lustre/lnet/selftest/timer.c
@@ -157,7 +157,7 @@ stt_check_timers(unsigned long *last)
 
 	while (cfs_time_aftereq(this_slot, *last)) {
 		expired += stt_expire_list(STTIMER_SLOT(this_slot), now);
-		this_slot = cfs_time_sub(this_slot, STTIMER_SLOTTIME);
+		this_slot = this_slot - STTIMER_SLOTTIME;
 	}
 
 	*last = now & STTIMER_SLOTTIMEMASK;
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index f4824d8ec741..d13db55b7242 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -556,7 +556,7 @@ struct ptlrpc_cli_req {
 	/** optional time limit for send attempts */
 	long				 cr_delay_limit;
 	/** time request was first queued */
-	time_t				 cr_queued_time;
+	unsigned long			 cr_queued_time;
 	/** request sent timeval */
 	struct timespec64		 cr_sent_tv;
 	/** time for request really sent out */
@@ -2253,8 +2253,7 @@ static inline int ptlrpc_req_get_repsize(struct ptlrpc_request *req)
 static inline int ptlrpc_send_limit_expired(struct ptlrpc_request *req)
 {
 	if (req->rq_delay_limit != 0 &&
-	    time_before(cfs_time_add(req->rq_queued_time,
-				     req->rq_delay_limit * HZ),
+	    time_before(req->rq_queued_time + req->rq_delay_limit * HZ,
 			jiffies)) {
 		return 1;
 	}
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index ab4dd15c8dd4..150e78c9eb68 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -326,8 +326,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
 	if (lock->l_granted_mode == LCK_PW &&
 	    !lock->l_readers && !lock->l_writers &&
 	    cfs_time_after(jiffies,
-			   cfs_time_add(lock->l_last_used,
-					10 * HZ))) {
+			   lock->l_last_used + 10 * HZ)) {
 		unlock_res_and_lock(lock);
 		if (ldlm_bl_to_thread_lock(ns, NULL, lock))
 			ldlm_handle_bl_callback(ns, NULL, lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 0e1b21c1f06d..6eb42f16040d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1176,13 +1176,12 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 	 * Despite of the LV, It doesn't make sense to keep the lock which
 	 * is unused for ns_max_age time.
 	 */
-	if (cfs_time_after(jiffies,
-			   cfs_time_add(lock->l_last_used, ns->ns_max_age)))
+	if (cfs_time_after(jiffies, lock->l_last_used + ns->ns_max_age))
 		return LDLM_POLICY_CANCEL_LOCK;
 
 	slv = ldlm_pool_get_slv(pl);
 	lvf = ldlm_pool_get_lvf(pl);
-	la = cfs_duration_sec(cfs_time_sub(cur, lock->l_last_used));
+	la = cfs_duration_sec(cur - lock->l_last_used);
 	lv = lvf * la * unused;
 
 	/* Inform pool about current CLV to see it via debugfs. */
@@ -1233,8 +1232,7 @@ static enum ldlm_policy_res ldlm_cancel_aged_policy(struct ldlm_namespace *ns,
 						    int count)
 {
 	if ((added >= count) &&
-	    time_before(jiffies,
-			cfs_time_add(lock->l_last_used, ns->ns_max_age)))
+	    time_before(jiffies, lock->l_last_used + ns->ns_max_age))
 		return LDLM_POLICY_KEEP_LOCK;
 
 	return LDLM_POLICY_CANCEL_LOCK;
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index c5dc894a4c1b..154d1721636e 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -327,8 +327,7 @@ int osc_object_is_contended(struct osc_object *obj)
 	 * I like copy-paste. the code is copied from
 	 * ll_file_is_contended.
 	 */
-	retry_time = cfs_time_add(obj->oo_contention_time,
-				  osc_contention_time * HZ);
+	retry_time = obj->oo_contention_time + osc_contention_time * HZ;
 	if (cfs_time_after(cur_time, retry_time)) {
 		osc_object_clear_contended(obj);
 		return 0;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 57c7db47e249..e836591c5936 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -141,8 +141,7 @@ static long pinger_check_timeout(unsigned long time)
 	}
 	mutex_unlock(&pinger_mutex);
 
-	return cfs_time_sub(cfs_time_add(time, timeout * HZ),
-					 jiffies);
+	return time + timeout * HZ - jiffies;
 }
 
 static bool ir_up;
@@ -238,8 +237,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 			/* obd_timeout might have changed */
 			if (imp->imp_pingable && imp->imp_next_ping &&
 			    cfs_time_after(imp->imp_next_ping,
-					   cfs_time_add(this_ping,
-							PING_INTERVAL * HZ)))
+					   this_ping + PING_INTERVAL * HZ))
 				ptlrpc_update_next_ping(imp, 0);
 		}
 		mutex_unlock(&pinger_mutex);
@@ -255,8 +253,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 		 */
 		CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
 		       time_to_next_wake,
-		       cfs_time_add(this_ping,
-				    PING_INTERVAL * HZ));
+		       this_ping + PING_INTERVAL * HZ);
 	} while (time_to_next_wake <= 0);
 
 	queue_delayed_work(pinger_wq, &ping_work,
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index fc29efbd9914..e71046db28e5 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -1153,7 +1153,7 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
 		spin_unlock(&svcpt->scp_at_lock);
 		return;
 	}
-	delay = cfs_time_sub(jiffies, svcpt->scp_at_checktime);
+	delay = jiffies - svcpt->scp_at_checktime;
 	svcpt->scp_at_check = 0;
 
 	if (array->paa_count == 0) {

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 08/17] staging: lustre: add container_of_safe()
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

Luster has a container_of0() function which is similar to
container_of() but passes an IS_ERR_OR_NULL() pointer through
unchanged.
This could be generally useful: bcache at last has a similar function.

Naming is hard, but the precedent set by hlist_entry_safe() suggests
a _safe suffix might be most consistent.

So add container_of_safe() to kernel.h, and replace all occurrences of
container_of0() with one of
  - list_first_entry, list_next_entry, when that is a better fit,
  - container_of(), when the pointer is used as a validpointer in
    surrounding code,
  - container_of_safe() when there is no obviously better alternative.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   11 -----------
 drivers/staging/lustre/lustre/include/cl_object.h  |   10 +++++-----
 drivers/staging/lustre/lustre/include/lu_object.h  |    6 +++---
 drivers/staging/lustre/lustre/llite/llite_nfs.c    |    2 +-
 drivers/staging/lustre/lustre/llite/vvp_internal.h |    8 ++++----
 drivers/staging/lustre/lustre/lmv/lmv_internal.h   |    2 +-
 .../staging/lustre/lustre/lov/lov_cl_internal.h    |   18 +++++++++---------
 drivers/staging/lustre/lustre/lov/lov_internal.h   |    2 +-
 drivers/staging/lustre/lustre/obdclass/lu_object.c |    8 ++++----
 .../staging/lustre/lustre/obdecho/echo_client.c    |    2 +-
 .../staging/lustre/lustre/osc/osc_cl_internal.h    |   10 +++++-----
 drivers/staging/lustre/lustre/osc/osc_internal.h   |    2 +-
 drivers/staging/lustre/lustre/osc/osc_io.c         |    2 +-
 drivers/staging/lustre/lustre/osc/osc_object.c     |    2 +-
 include/linux/kernel.h                             |   16 ++++++++++++++++
 15 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 392793582956..3b751c436b3d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -99,17 +99,6 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
 int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
 int libcfs_ioctl(unsigned long cmd, void __user *arg);
 
-/* container_of depends on "likely" which is defined in libcfs_private.h */
-static inline void *__container_of(void *ptr, unsigned long shift)
-{
-	if (IS_ERR_OR_NULL(ptr))
-		return ptr;
-	return (char *)ptr - shift;
-}
-
-#define container_of0(ptr, type, member) \
-	((type *)__container_of((void *)(ptr), offsetof(type, member)))
-
 #define _LIBCFS_H
 
 extern struct miscdevice libcfs_dev;
diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
index 341a145c3331..6f7b991be809 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1941,7 +1941,7 @@ static inline int lu_device_is_cl(const struct lu_device *d)
 static inline struct cl_device *lu2cl_dev(const struct lu_device *d)
 {
 	LASSERT(!d || IS_ERR(d) || lu_device_is_cl(d));
-	return container_of0(d, struct cl_device, cd_lu_dev);
+	return container_of_safe(d, struct cl_device, cd_lu_dev);
 }
 
 static inline struct lu_device *cl2lu_dev(struct cl_device *d)
@@ -1952,13 +1952,13 @@ static inline struct lu_device *cl2lu_dev(struct cl_device *d)
 static inline struct cl_object *lu2cl(const struct lu_object *o)
 {
 	LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->lo_dev));
-	return container_of0(o, struct cl_object, co_lu);
+	return container_of_safe(o, struct cl_object, co_lu);
 }
 
 static inline const struct cl_object_conf *
 lu2cl_conf(const struct lu_object_conf *conf)
 {
-	return container_of0(conf, struct cl_object_conf, coc_lu);
+	return container_of_safe(conf, struct cl_object_conf, coc_lu);
 }
 
 static inline struct cl_object *cl_object_next(const struct cl_object *obj)
@@ -1969,12 +1969,12 @@ static inline struct cl_object *cl_object_next(const struct cl_object *obj)
 static inline struct cl_device *cl_object_device(const struct cl_object *o)
 {
 	LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev));
-	return container_of0(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
+	return container_of_safe(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
 }
 
 static inline struct cl_object_header *luh2coh(const struct lu_object_header *h)
 {
-	return container_of0(h, struct cl_object_header, coh_lu);
+	return container_of_safe(h, struct cl_object_header, coh_lu);
 }
 
 static inline struct cl_site *cl_object_site(const struct cl_object *obj)
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
index 35c7b582f36d..c3b0ed518819 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -745,15 +745,15 @@ struct lu_object *lu_object_find_slice(const struct lu_env *env,
 static inline struct lu_object *lu_object_top(struct lu_object_header *h)
 {
 	LASSERT(!list_empty(&h->loh_layers));
-	return container_of0(h->loh_layers.next, struct lu_object, lo_linkage);
+	return list_first_entry(&h->loh_layers, struct lu_object, lo_linkage);
 }
 
 /**
  * Next sub-object in the layering
  */
-static inline struct lu_object *lu_object_next(const struct lu_object *o)
+static inline const struct lu_object *lu_object_next(const struct lu_object *o)
 {
-	return container_of0(o->lo_linkage.next, struct lu_object, lo_linkage);
+	return list_next_entry(o, lo_linkage);
 }
 
 /**
diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c
index a6a1d80c711a..14172688d55f 100644
--- a/drivers/staging/lustre/lustre/llite/llite_nfs.c
+++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c
@@ -223,7 +223,7 @@ static int ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name,
 	/* It is hack to access lde_fid for comparison with lgd_fid.
 	 * So the input 'name' must be part of the 'lu_dirent'.
 	 */
-	struct lu_dirent *lde = container_of0(name, struct lu_dirent, lde_name);
+	struct lu_dirent *lde = container_of((void*)name, struct lu_dirent, lde_name);
 	struct ll_getname_data *lgd =
 		container_of(ctx, struct ll_getname_data, ctx);
 	struct lu_fid fid;
diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h
index 02ea5161d635..7d3abb43584a 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_internal.h
+++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h
@@ -263,22 +263,22 @@ static inline struct lu_device *vvp2lu_dev(struct vvp_device *vdv)
 
 static inline struct vvp_device *lu2vvp_dev(const struct lu_device *d)
 {
-	return container_of0(d, struct vvp_device, vdv_cl.cd_lu_dev);
+	return container_of_safe(d, struct vvp_device, vdv_cl.cd_lu_dev);
 }
 
 static inline struct vvp_device *cl2vvp_dev(const struct cl_device *d)
 {
-	return container_of0(d, struct vvp_device, vdv_cl);
+	return container_of_safe(d, struct vvp_device, vdv_cl);
 }
 
 static inline struct vvp_object *cl2vvp(const struct cl_object *obj)
 {
-	return container_of0(obj, struct vvp_object, vob_cl);
+	return container_of_safe(obj, struct vvp_object, vob_cl);
 }
 
 static inline struct vvp_object *lu2vvp(const struct lu_object *obj)
 {
-	return container_of0(obj, struct vvp_object, vob_cl.co_lu);
+	return container_of_safe(obj, struct vvp_object, vob_cl.co_lu);
 }
 
 static inline struct inode *vvp_object_inode(const struct cl_object *obj)
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
index c27c3c32188d..68a99170c424 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h
+++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
@@ -60,7 +60,7 @@ int lmv_revalidate_slaves(struct obd_export *exp,
 
 static inline struct obd_device *lmv2obd_dev(struct lmv_obd *lmv)
 {
-	return container_of0(lmv, struct obd_device, u.lmv);
+	return container_of_safe(lmv, struct obd_device, u.lmv);
 }
 
 static inline struct lmv_tgt_desc *
diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
index 1185eceaf497..2e9c75ebdda5 100644
--- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
@@ -496,7 +496,7 @@ static inline struct lu_device *lov2lu_dev(struct lov_device *lov)
 static inline struct lov_device *lu2lov_dev(const struct lu_device *d)
 {
 	LINVRNT(d->ld_type == &lov_device_type);
-	return container_of0(d, struct lov_device, ld_cl.cd_lu_dev);
+	return container_of(d, struct lov_device, ld_cl.cd_lu_dev);
 }
 
 static inline struct cl_device *lovsub2cl_dev(struct lovsub_device *lovsub)
@@ -512,13 +512,13 @@ static inline struct lu_device *lovsub2lu_dev(struct lovsub_device *lovsub)
 static inline struct lovsub_device *lu2lovsub_dev(const struct lu_device *d)
 {
 	LINVRNT(d->ld_type == &lovsub_device_type);
-	return container_of0(d, struct lovsub_device, acid_cl.cd_lu_dev);
+	return container_of(d, struct lovsub_device, acid_cl.cd_lu_dev);
 }
 
 static inline struct lovsub_device *cl2lovsub_dev(const struct cl_device *d)
 {
 	LINVRNT(d->cd_lu_dev.ld_type == &lovsub_device_type);
-	return container_of0(d, struct lovsub_device, acid_cl);
+	return container_of(d, struct lovsub_device, acid_cl);
 }
 
 static inline struct lu_object *lov2lu(struct lov_object *lov)
@@ -534,13 +534,13 @@ static inline struct cl_object *lov2cl(struct lov_object *lov)
 static inline struct lov_object *lu2lov(const struct lu_object *obj)
 {
 	LINVRNT(lov_is_object(obj));
-	return container_of0(obj, struct lov_object, lo_cl.co_lu);
+	return container_of(obj, struct lov_object, lo_cl.co_lu);
 }
 
 static inline struct lov_object *cl2lov(const struct cl_object *obj)
 {
 	LINVRNT(lov_is_object(&obj->co_lu));
-	return container_of0(obj, struct lov_object, lo_cl);
+	return container_of(obj, struct lov_object, lo_cl);
 }
 
 static inline struct lu_object *lovsub2lu(struct lovsub_object *los)
@@ -556,13 +556,13 @@ static inline struct cl_object *lovsub2cl(struct lovsub_object *los)
 static inline struct lovsub_object *cl2lovsub(const struct cl_object *obj)
 {
 	LINVRNT(lovsub_is_object(&obj->co_lu));
-	return container_of0(obj, struct lovsub_object, lso_cl);
+	return container_of(obj, struct lovsub_object, lso_cl);
 }
 
 static inline struct lovsub_object *lu2lovsub(const struct lu_object *obj)
 {
 	LINVRNT(lovsub_is_object(obj));
-	return container_of0(obj, struct lovsub_object, lso_cl.co_lu);
+	return container_of(obj, struct lovsub_object, lso_cl.co_lu);
 }
 
 static inline struct lovsub_lock *
@@ -590,14 +590,14 @@ static inline struct lov_lock *cl2lov_lock(const struct cl_lock_slice *slice)
 static inline struct lov_page *cl2lov_page(const struct cl_page_slice *slice)
 {
 	LINVRNT(lov_is_object(&slice->cpl_obj->co_lu));
-	return container_of0(slice, struct lov_page, lps_cl);
+	return container_of(slice, struct lov_page, lps_cl);
 }
 
 static inline struct lovsub_page *
 cl2lovsub_page(const struct cl_page_slice *slice)
 {
 	LINVRNT(lovsub_is_object(&slice->cpl_obj->co_lu));
-	return container_of0(slice, struct lovsub_page, lsb_cl);
+	return container_of(slice, struct lovsub_page, lsb_cl);
 }
 
 static inline struct lov_io *cl2lov_io(const struct lu_env *env,
diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h
index a56d71c2dda2..27f60dd7ab9a 100644
--- a/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -277,7 +277,7 @@ static inline bool lov_oinfo_is_dummy(const struct lov_oinfo *loi)
 
 static inline struct obd_device *lov2obd(const struct lov_obd *lov)
 {
-	return container_of0(lov, struct obd_device, u.lov);
+	return container_of_safe(lov, struct obd_device, u.lov);
 }
 
 #endif
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 8ddf23b82a2c..6db5d95d4b36 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -319,7 +319,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o)
 		 * lives as long as possible and ->loo_object_free() methods
 		 * can look at its contents.
 		 */
-		o = container_of0(splice.prev, struct lu_object, lo_linkage);
+		o = container_of(splice.prev, struct lu_object, lo_linkage);
 		list_del_init(&o->lo_linkage);
 		o->lo_ops->loo_object_free(env, o);
 	}
@@ -404,8 +404,8 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s,
 		 * races due to the reasons described in lu_object_put().
 		 */
 		while (!list_empty(&dispose)) {
-			h = container_of0(dispose.next,
-					  struct lu_object_header, loh_lru);
+			h = container_of(dispose.next,
+					 struct lu_object_header, loh_lru);
 			list_del_init(&h->loh_lru);
 			lu_object_free(env, lu_object_top(h));
 			lprocfs_counter_incr(s->ls_stats, LU_SS_LRU_PURGED);
@@ -579,7 +579,7 @@ static struct lu_object *htable_lookup(struct lu_site *s,
 		return ERR_PTR(-ENOENT);
 	}
 
-	h = container_of0(hnode, struct lu_object_header, loh_hash);
+	h = container_of(hnode, struct lu_object_header, loh_hash);
 	if (likely(!lu_object_is_dying(h))) {
 		cfs_hash_get(s->ls_obj_hash, hnode);
 		lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index 99a76db51ae0..767067b61109 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -99,7 +99,7 @@ static int echo_client_cleanup(struct obd_device *obddev);
  */
 static inline struct echo_device *cl2echo_dev(const struct cl_device *dev)
 {
-	return container_of0(dev, struct echo_device, ed_cl);
+	return container_of_safe(dev, struct echo_device, ed_cl);
 }
 
 static inline struct cl_device *echo_dev2cl(struct echo_device *d)
diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
index 1449013722f6..dc25dd12d7d5 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
@@ -460,7 +460,7 @@ static inline int osc_is_object(const struct lu_object *obj)
 static inline struct osc_device *lu2osc_dev(const struct lu_device *d)
 {
 	LINVRNT(d->ld_type == &osc_device_type);
-	return container_of0(d, struct osc_device, od_cl.cd_lu_dev);
+	return container_of(d, struct osc_device, od_cl.cd_lu_dev);
 }
 
 static inline struct obd_export *osc_export(const struct osc_object *obj)
@@ -476,7 +476,7 @@ static inline struct client_obd *osc_cli(const struct osc_object *obj)
 static inline struct osc_object *cl2osc(const struct cl_object *obj)
 {
 	LINVRNT(osc_is_object(&obj->co_lu));
-	return container_of0(obj, struct osc_object, oo_cl);
+	return container_of(obj, struct osc_object, oo_cl);
 }
 
 static inline struct cl_object *osc2cl(const struct osc_object *obj)
@@ -509,12 +509,12 @@ static inline enum cl_lock_mode osc_ldlm2cl_lock(enum ldlm_mode mode)
 static inline struct osc_page *cl2osc_page(const struct cl_page_slice *slice)
 {
 	LINVRNT(osc_is_object(&slice->cpl_obj->co_lu));
-	return container_of0(slice, struct osc_page, ops_cl);
+	return container_of(slice, struct osc_page, ops_cl);
 }
 
 static inline struct osc_page *oap2osc(struct osc_async_page *oap)
 {
-	return container_of0(oap, struct osc_page, ops_oap);
+	return container_of_safe(oap, struct osc_page, ops_oap);
 }
 
 static inline pgoff_t osc_index(struct osc_page *opg)
@@ -545,7 +545,7 @@ osc_cl_page_osc(struct cl_page *page, struct osc_object *osc)
 static inline struct osc_lock *cl2osc_lock(const struct cl_lock_slice *slice)
 {
 	LINVRNT(osc_is_object(&slice->cls_obj->co_lu));
-	return container_of0(slice, struct osc_lock, ols_cl);
+	return container_of(slice, struct osc_lock, ols_cl);
 }
 
 static inline struct osc_lock *osc_lock_at(const struct cl_lock *lock)
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h
index 32db150fd42e..be8c7829b3de 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -180,7 +180,7 @@ struct osc_device {
 
 static inline struct osc_device *obd2osc_dev(const struct obd_device *d)
 {
-	return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
+	return container_of_safe(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
 }
 
 extern struct lu_kmem_descr osc_caches[];
diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c
index 76743faf3e6d..67734a8ed331 100644
--- a/drivers/staging/lustre/lustre/osc/osc_io.c
+++ b/drivers/staging/lustre/lustre/osc/osc_io.c
@@ -55,7 +55,7 @@
 static struct osc_io *cl2osc_io(const struct lu_env *env,
 				const struct cl_io_slice *slice)
 {
-	struct osc_io *oio = container_of0(slice, struct osc_io, oi_cl);
+	struct osc_io *oio = container_of_safe(slice, struct osc_io, oi_cl);
 
 	LINVRNT(oio == osc_env_io(env));
 	return oio;
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index 6baa8e2e00c9..9582d5a642e2 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -58,7 +58,7 @@ static struct lu_object *osc2lu(struct osc_object *osc)
 static struct osc_object *lu2osc(const struct lu_object *obj)
 {
 	LINVRNT(osc_is_object(obj));
-	return container_of0(obj, struct osc_object, oo_cl.co_lu);
+	return container_of(obj, struct osc_object, oo_cl.co_lu);
 }
 
 /*****************************************************************************
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2da80e079d56..e5e991642d8f 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -941,6 +941,22 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
 			 "pointer type mismatch in container_of()");	\
 	((type *)(__mptr - offsetof(type, member))); })
 
+/**
+ * container_of_safe - cast a member of a structure out to the containing structure
+ * @ptr:	the pointer to the member.
+ * @type:	the type of the container struct this is embedded in.
+ * @member:	the name of the member within the struct.
+ *
+ * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged.
+ */
+#define container_of_safe(ptr, type, member) ({				\
+	void *__mptr = (void *)(ptr);					\
+	BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&	\
+			 !__same_type(*(ptr), void),			\
+			 "pointer type mismatch in container_of()");	\
+	IS_ERR_OR_NULL(ptr) ? ERR_CAST(ptr) :				\
+		((type *)(__mptr - offsetof(type, member))); })
+
 /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 07/17] staging: lustre: ldlm: free resource when ldlm_lock_create() fails.
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

ldlm_lock_create() gets a resource, but don't put it on
all failure paths. It should.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index b8fd778d9832..614caa4a9b0e 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1551,8 +1551,10 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
 		return ERR_CAST(res);
 
 	lock = ldlm_lock_new(res);
-	if (!lock)
+	if (!lock) {
+		ldlm_resource_putref(res);
 		return ERR_PTR(-ENOMEM);
+	}
 
 	lock->l_req_mode = mode;
 	lock->l_ast_data = data;
@@ -1595,6 +1597,8 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
 	return ERR_PTR(rc);
 }
 
+
+
 /**
  * Enqueue (request) a lock.
  * On the client this is called from ldlm_cli_enqueue_fini

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 06/17] staging: lustre: tidy up ldlm_resource_putref()
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

1/ the return value of ldlm_resource_putref() is never
  used, so change it to return 'void'.
2/ Move all of the code to run on the last putref to
   __ldlm_resource_putref_final().  This means a lock
   is taken in one function and dropped in another, but
   that isn't too uncommon, and will disappear in a future
   patch.
   Now that the code it together, it becomes apparent that
   we are dropping a ref on the namespace *before* the last
   use.  So keep the ref until after.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |    2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   21 +++++++++-----------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 5a355fbab401..d668d86423a4 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -1190,7 +1190,7 @@ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
 					struct ldlm_resource *parent,
 					const struct ldlm_res_id *,
 					enum ldlm_type type, int create);
-int ldlm_resource_putref(struct ldlm_resource *res);
+void ldlm_resource_putref(struct ldlm_resource *res);
 void ldlm_resource_add_lock(struct ldlm_resource *res,
 			    struct list_head *head,
 			    struct ldlm_lock *lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 4c44603ab6f9..8841a1bb2c0a 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1195,6 +1195,7 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
 					 struct ldlm_resource *res)
 {
 	struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
+	struct ldlm_namespace *ns = nsb->nsb_namespace;
 
 	if (!list_empty(&res->lr_granted)) {
 		ldlm_resource_dump(D_ERROR, res);
@@ -1206,15 +1207,18 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
 		LBUG();
 	}
 
-	cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash,
+	cfs_hash_bd_del_locked(ns->ns_rs_hash,
 			       bd, &res->lr_hash);
 	lu_ref_fini(&res->lr_reference);
+	cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1);
+	if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
+		ns->ns_lvbo->lvbo_free(res);
 	if (cfs_hash_bd_count_get(bd) == 0)
-		ldlm_namespace_put(nsb->nsb_namespace);
+		ldlm_namespace_put(ns);
+	kmem_cache_free(ldlm_resource_slab, res);
 }
 
-/* Returns 1 if the resource was freed, 0 if it remains. */
-int ldlm_resource_putref(struct ldlm_resource *res)
+void ldlm_resource_putref(struct ldlm_resource *res)
 {
 	struct ldlm_namespace *ns = ldlm_res_to_ns(res);
 	struct cfs_hash_bd   bd;
@@ -1224,15 +1228,8 @@ int ldlm_resource_putref(struct ldlm_resource *res)
 	       res, atomic_read(&res->lr_refcount) - 1);
 
 	cfs_hash_bd_get(ns->ns_rs_hash, &res->lr_name, &bd);
-	if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) {
+	if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount))
 		__ldlm_resource_putref_final(&bd, res);
-		cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
-		if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
-			ns->ns_lvbo->lvbo_free(res);
-		kmem_cache_free(ldlm_resource_slab, res);
-		return 1;
-	}
-	return 0;
 }
 EXPORT_SYMBOL(ldlm_resource_putref);
 

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 05/17] staging: lustre: remove unneeded include.
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

cfs_hash usage was removed from cl_object.c
some time ago, so remove the #include as well.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/obdclass/cl_object.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index 7809f6ae1809..f1641645acae 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -53,7 +53,6 @@
 #include <obd_support.h>
 #include <lustre_fid.h>
 #include <linux/list.h>
-#include <linux/libcfs/libcfs_hash.h>	/* for cfs_hash stuff */
 #include <cl_object.h>
 #include <lu_object.h>
 #include "cl_internal.h"

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 04/17] staging: lustre: remove unused hash tables.
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

exp_lock_hash and exp_flock_hash are unused in
the client, so remove all references.

Also remove unused hashtable size definitions.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |   10 -------
 .../staging/lustre/lustre/include/lustre_export.h  |    7 -----
 .../staging/lustre/lustre/include/obd_support.h    |   18 -------------
 drivers/staging/lustre/lustre/ldlm/ldlm_flock.c    |   11 +-------
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   14 ----------
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   27 +-------------------
 drivers/staging/lustre/lustre/obdclass/genops.c    |    2 -
 7 files changed, 3 insertions(+), 86 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 7407acf60cf8..5a355fbab401 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -629,16 +629,6 @@ struct ldlm_lock {
 	 * Tree node for ldlm_extent.
 	 */
 	struct ldlm_interval	*l_tree_node;
-	/**
-	 * Per export hash of locks.
-	 * Protected by per-bucket exp->exp_lock_hash locks.
-	 */
-	struct hlist_node	l_exp_hash;
-	/**
-	 * Per export hash of flock locks.
-	 * Protected by per-bucket exp->exp_flock_hash locks.
-	 */
-	struct hlist_node	l_exp_flock_hash;
 	/**
 	 * Requested mode.
 	 * Protected by lr_lock.
diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h
index 40cd168ed2ea..19ce13bc8ee6 100644
--- a/drivers/staging/lustre/lustre/include/lustre_export.h
+++ b/drivers/staging/lustre/lustre/include/lustre_export.h
@@ -102,13 +102,6 @@ struct obd_export {
 	struct ptlrpc_connection *exp_connection;
 	/** Connection count value from last successful reconnect rpc */
 	__u32		     exp_conn_cnt;
-	/** Hash list of all ldlm locks granted on this export */
-	struct cfs_hash	       *exp_lock_hash;
-	/**
-	 * Hash list for Posix lock deadlock detection, added with
-	 * ldlm_lock::l_exp_flock_hash.
-	 */
-	struct cfs_hash	       *exp_flock_hash;
 	struct list_head		exp_outstanding_replies;
 	struct list_head		exp_uncommitted_replies;
 	spinlock_t		  exp_uncommitted_replies_lock;
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
index 8595091b8b86..eb2d6cb6b40b 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -67,27 +67,9 @@ extern char obd_jobid_var[];
 #define HASH_UUID_BKT_BITS 5
 #define HASH_UUID_CUR_BITS 7
 #define HASH_UUID_MAX_BITS 12
-#define HASH_NID_BKT_BITS 5
-#define HASH_NID_CUR_BITS 7
-#define HASH_NID_MAX_BITS 12
-#define HASH_NID_STATS_BKT_BITS 5
-#define HASH_NID_STATS_CUR_BITS 7
-#define HASH_NID_STATS_MAX_BITS 12
-#define HASH_LQE_BKT_BITS 5
-#define HASH_LQE_CUR_BITS 7
-#define HASH_LQE_MAX_BITS 12
 #define HASH_CONN_BKT_BITS 5
 #define HASH_CONN_CUR_BITS 5
 #define HASH_CONN_MAX_BITS 15
-#define HASH_EXP_LOCK_BKT_BITS  5
-#define HASH_EXP_LOCK_CUR_BITS  7
-#define HASH_EXP_LOCK_MAX_BITS  16
-#define HASH_CL_ENV_BKT_BITS    5
-#define HASH_CL_ENV_BITS	10
-#define HASH_JOB_STATS_BKT_BITS 5
-#define HASH_JOB_STATS_CUR_BITS 7
-#define HASH_JOB_STATS_MAX_BITS 12
-
 /* Timeout definitions */
 #define OBD_TIMEOUT_DEFAULT	     100
 /* Time to wait for all clients to reconnect during recovery (hard limit) */
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
index 411b540b96d9..94f3b1e49896 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
@@ -83,9 +83,6 @@ ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode)
 	LDLM_DEBUG(lock, "%s(mode: %d)",
 		   __func__, mode);
 
-	/* Safe to not lock here, since it should be empty anyway */
-	LASSERT(hlist_unhashed(&lock->l_exp_flock_hash));
-
 	list_del_init(&lock->l_res_link);
 
 	/* client side - set a flag to prevent sending a CANCEL */
@@ -263,15 +260,9 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req)
 		lock->l_policy_data.l_flock.start =
 			new->l_policy_data.l_flock.end + 1;
 		new2->l_conn_export = lock->l_conn_export;
-		if (lock->l_export) {
+		if (lock->l_export)
 			new2->l_export = class_export_lock_get(lock->l_export,
 							       new2);
-			if (new2->l_export->exp_lock_hash &&
-			    hlist_unhashed(&new2->l_exp_hash))
-				cfs_hash_add(new2->l_export->exp_lock_hash,
-					     &new2->l_remote_handle,
-					     &new2->l_exp_hash);
-		}
 		ldlm_lock_addref_internal_nolock(new2,
 						 lock->l_granted_mode);
 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 95bea351d21d..b8fd778d9832 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -318,18 +318,6 @@ static int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
 	}
 	ldlm_set_destroyed(lock);
 
-	if (lock->l_export && lock->l_export->exp_lock_hash) {
-		/* NB: it's safe to call cfs_hash_del() even lock isn't
-		 * in exp_lock_hash.
-		 */
-		/* In the function below, .hs_keycmp resolves to
-		 * ldlm_export_lock_keycmp()
-		 */
-		/* coverity[overrun-buffer-val] */
-		cfs_hash_del(lock->l_export->exp_lock_hash,
-			     &lock->l_remote_handle, &lock->l_exp_hash);
-	}
-
 	ldlm_lock_remove_from_lru(lock);
 	class_handle_unhash(&lock->l_handle);
 
@@ -419,8 +407,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
 	lock->l_blocking_lock = NULL;
 	INIT_LIST_HEAD(&lock->l_sl_mode);
 	INIT_LIST_HEAD(&lock->l_sl_policy);
-	INIT_HLIST_NODE(&lock->l_exp_hash);
-	INIT_HLIST_NODE(&lock->l_exp_flock_hash);
 
 	lprocfs_counter_incr(ldlm_res_to_ns(resource)->ns_stats,
 			     LDLM_NSS_LOCKS);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index be43958e4090..8e79f5e073ff 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -405,19 +405,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
 	cleanup_phase = 0;
 
 	lock_res_and_lock(lock);
-	/* Key change rehash lock in per-export hash with new key */
-	if (exp->exp_lock_hash) {
-		/* In the function below, .hs_keycmp resolves to
-		 * ldlm_export_lock_keycmp()
-		 */
-		/* coverity[overrun-buffer-val] */
-		cfs_hash_rehash_key(exp->exp_lock_hash,
-				    &lock->l_remote_handle,
-				    &reply->lock_handle,
-				    &lock->l_exp_hash);
-	} else {
-		lock->l_remote_handle = reply->lock_handle;
-	}
+	lock->l_remote_handle = reply->lock_handle;
 
 	*flags = ldlm_flags_from_wire(reply->lock_flags);
 	lock->l_flags |= ldlm_flags_from_wire(reply->lock_flags &
@@ -1884,18 +1872,7 @@ static int replay_lock_interpret(const struct lu_env *env,
 
 	/* Key change rehash lock in per-export hash with new key */
 	exp = req->rq_export;
-	if (exp && exp->exp_lock_hash) {
-		/* In the function below, .hs_keycmp resolves to
-		 * ldlm_export_lock_keycmp()
-		 */
-		/* coverity[overrun-buffer-val] */
-		cfs_hash_rehash_key(exp->exp_lock_hash,
-				    &lock->l_remote_handle,
-				    &reply->lock_handle,
-				    &lock->l_exp_hash);
-	} else {
-		lock->l_remote_handle = reply->lock_handle;
-	}
+	lock->l_remote_handle = reply->lock_handle;
 
 	LDLM_DEBUG(lock, "replayed lock:");
 	ptlrpc_import_recovery_state_machine(req->rq_import);
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 63ccbabb4c5a..86e22472719a 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -721,8 +721,6 @@ struct obd_export *class_new_export(struct obd_device *obd,
 		return ERR_PTR(-ENOMEM);
 
 	export->exp_conn_cnt = 0;
-	export->exp_lock_hash = NULL;
-	export->exp_flock_hash = NULL;
 	atomic_set(&export->exp_refcount, 2);
 	atomic_set(&export->exp_rpc_count, 0);
 	atomic_set(&export->exp_cb_count, 0);

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 02/17] staging: lustre: remove unused ldlm_completion_ast_async()
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

This function is unused.

Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |    1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   23 --------------------
 2 files changed, 24 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 239aa2b1268f..7407acf60cf8 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -1227,7 +1227,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
  * processing.
  * @{
  */
-int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data);
 int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data);
 /** @} ldlm_local_ast */
 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index c3c9186b74ce..be43958e4090 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -191,29 +191,6 @@ static int ldlm_completion_tail(struct ldlm_lock *lock, void *data)
 	return result;
 }
 
-/**
- * Implementation of ->l_completion_ast() for a client, that doesn't wait
- * until lock is granted. Suitable for locks enqueued through ptlrpcd, of
- * other threads that cannot block for long.
- */
-int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data)
-{
-	if (flags == LDLM_FL_WAIT_NOREPROC) {
-		LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock");
-		return 0;
-	}
-
-	if (!(flags & LDLM_FL_BLOCKED_MASK)) {
-		wake_up(&lock->l_waitq);
-		return ldlm_completion_tail(lock, data);
-	}
-
-	LDLM_DEBUG(lock,
-		   "client-side enqueue returned a blocked lock, going forward");
-	return 0;
-}
-EXPORT_SYMBOL(ldlm_completion_ast_async);
-
 /**
  * Generic LDLM "completion" AST. This is called in several cases:
  *

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [PATCH 01/17] staging: lustre: remove invariant in cl_io_read_ahead()
  2018-03-29  4:26 ` [lustre-devel] " NeilBrown
@ 2018-03-29  4:26   ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

This invariant can fail as ci_type is somtimes CIS_INIT.

According to Jinshan Xiong, or of the most recent significant
change to this code, "We should get rid of it."

So do that.

Fixes: 1e1db2a97be5 ("staging: lustre: clio: Revise read ahead implementation")
Cc: Jinshan Xiong <jinshan.xiong@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/obdclass/cl_io.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c
index ab84e011b560..fcdae6029258 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
@@ -599,7 +599,6 @@ int cl_io_read_ahead(const struct lu_env *env, struct cl_io *io,
 	int		       result = 0;
 
 	LINVRNT(io->ci_type == CIT_READ || io->ci_type == CIT_FAULT);
-	LINVRNT(io->ci_state == CIS_IO_GOING || io->ci_state == CIS_LOCKED);
 	LINVRNT(cl_io_invariant(io));
 
 	cl_io_for_each(scan, io) {

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 00/17] staging: Assorted lustre cleanup
@ 2018-03-29  4:26 ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

I'm currently working on converting lustre to use
rhashtables instead of its own resizeable hash tables.
That is progressing well, but I need some changes to
rhashtable first, and that will take a little while.
So here are some other patches.
Some are cleanups related to hashtables,
some are related to measuring time in jiffies
and some are random other things I found as I was looking
at stuff.

James, if this jiffie stuff conflicts with your time-keeping stuff, we
can just drop it.  Last time I cleaned up jiffie-related code you
said it didn't conflict significantly, so I'm hoping this won't
either.

Thanks,
NeilBrown


---

NeilBrown (17):
      staging: lustre: remove invariant in cl_io_read_ahead()
      staging: lustre: remove unused ldlm_completion_ast_async()
      staging: lustre: LNET excludes USERIO
      staging: lustre: remove unused hash tables.
      staging: lustre: remove unneeded include.
      staging: lustre: tidy up ldlm_resource_putref()
      staging: lustre: ldlm: free resource when ldlm_lock_create() fails.
      staging: lustre: add container_of_safe()
      staging: lustre: cfs_time_current() -> jiffies.
      staging: lustre: libcfs: discard cfs_time_add/sub
      staging: lustre: libcfs: discard cfs_time_shift().
      staging: lustre: libcfs: discard cfs_time_after()
      staging: lustre: libcfs: remove cfs_timeout_cap()
      staging: lustre: discard cfs_duration_sec()
      staging: lustre: discard cfs_time_before_64()
      staging: lustre: discard linux-time.h
      staging: lustre: remove cruft from libcfs/linux/libcfs.h


 .../staging/lustre/include/linux/libcfs/curproc.h  |    2 
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   17 +--
 .../lustre/include/linux/libcfs/libcfs_time.h      |   79 ---------------
 .../lustre/include/linux/libcfs/linux/libcfs.h     |   18 ---
 .../lustre/include/linux/libcfs/linux/linux-time.h |  103 --------------------
 drivers/staging/lustre/lnet/Kconfig                |    2 
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   32 +++---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |    6 +
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |   17 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |   15 +--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   87 ++++++++---------
 drivers/staging/lustre/lnet/libcfs/debug.c         |    2 
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |   12 +-
 drivers/staging/lustre/lnet/lnet/lib-move.c        |   14 +--
 drivers/staging/lustre/lnet/lnet/net_fault.c       |   40 ++++----
 drivers/staging/lustre/lnet/lnet/peer.c            |    2 
 drivers/staging/lustre/lnet/lnet/router.c          |   17 ++-
 drivers/staging/lustre/lnet/lnet/router_proc.c     |   13 +--
 drivers/staging/lustre/lnet/selftest/conrpc.c      |   14 +--
 drivers/staging/lustre/lnet/selftest/console.c     |    4 -
 drivers/staging/lustre/lnet/selftest/framework.c   |    2 
 drivers/staging/lustre/lnet/selftest/timer.c       |    4 -
 drivers/staging/lustre/lustre/include/cl_object.h  |   10 +-
 drivers/staging/lustre/lustre/include/lu_object.h  |    6 +
 drivers/staging/lustre/lustre/include/lustre_dlm.h |   13 ---
 .../staging/lustre/lustre/include/lustre_export.h  |    7 -
 drivers/staging/lustre/lustre/include/lustre_net.h |    7 +
 drivers/staging/lustre/lustre/include/obd_class.h  |   10 +-
 .../staging/lustre/lustre/include/obd_support.h    |   18 ---
 drivers/staging/lustre/lustre/ldlm/ldlm_flock.c    |   11 --
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   22 +---
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    5 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   66 ++-----------
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   25 ++---
 .../staging/lustre/lustre/llite/llite_internal.h   |    2 
 drivers/staging/lustre/lustre/llite/llite_lib.c    |    4 -
 drivers/staging/lustre/lustre/llite/llite_nfs.c    |    2 
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +-
 drivers/staging/lustre/lustre/llite/statahead.c    |    4 -
 drivers/staging/lustre/lustre/llite/vvp_internal.h |    8 +-
 drivers/staging/lustre/lustre/lmv/lmv_internal.h   |    2 
 drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    2 
 .../staging/lustre/lustre/lov/lov_cl_internal.h    |   18 ++-
 drivers/staging/lustre/lustre/lov/lov_internal.h   |    2 
 drivers/staging/lustre/lustre/lov/lov_obd.c        |    2 
 drivers/staging/lustre/lustre/lov/lov_request.c    |    4 -
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 
 drivers/staging/lustre/lustre/obdclass/cl_io.c     |    1 
 drivers/staging/lustre/lustre/obdclass/cl_object.c |    1 
 drivers/staging/lustre/lustre/obdclass/genops.c    |    2 
 .../lustre/lustre/obdclass/lprocfs_status.c        |   12 +-
 drivers/staging/lustre/lustre/obdclass/lu_object.c |    8 +-
 .../staging/lustre/lustre/obdclass/obd_config.c    |    2 
 .../staging/lustre/lustre/obdecho/echo_client.c    |    2 
 drivers/staging/lustre/lustre/osc/osc_cache.c      |    2 
 .../staging/lustre/lustre/osc/osc_cl_internal.h    |   10 +-
 drivers/staging/lustre/lustre/osc/osc_internal.h   |    2 
 drivers/staging/lustre/lustre/osc/osc_io.c         |    2 
 drivers/staging/lustre/lustre/osc/osc_object.c     |   11 +-
 drivers/staging/lustre/lustre/osc/osc_page.c       |    4 -
 drivers/staging/lustre/lustre/osc/osc_request.c    |    6 +
 drivers/staging/lustre/lustre/ptlrpc/client.c      |    4 -
 drivers/staging/lustre/lustre/ptlrpc/import.c      |   10 +-
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |   23 ++--
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    6 +
 include/linux/kernel.h                             |   16 +++
 66 files changed, 284 insertions(+), 606 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h

--
Signature

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 02/17] staging: lustre: remove unused ldlm_completion_ast_async()
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

This function is unused.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |    1 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   23 --------------------
 2 files changed, 24 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 239aa2b1268f..7407acf60cf8 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -1227,7 +1227,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
  * processing.
  * @{
  */
-int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data);
 int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data);
 /** @} ldlm_local_ast */
 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index c3c9186b74ce..be43958e4090 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -191,29 +191,6 @@ static int ldlm_completion_tail(struct ldlm_lock *lock, void *data)
 	return result;
 }
 
-/**
- * Implementation of ->l_completion_ast() for a client, that doesn't wait
- * until lock is granted. Suitable for locks enqueued through ptlrpcd, of
- * other threads that cannot block for long.
- */
-int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data)
-{
-	if (flags == LDLM_FL_WAIT_NOREPROC) {
-		LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock");
-		return 0;
-	}
-
-	if (!(flags & LDLM_FL_BLOCKED_MASK)) {
-		wake_up(&lock->l_waitq);
-		return ldlm_completion_tail(lock, data);
-	}
-
-	LDLM_DEBUG(lock,
-		   "client-side enqueue returned a blocked lock, going forward");
-	return 0;
-}
-EXPORT_SYMBOL(ldlm_completion_ast_async);
-
 /**
  * Generic LDLM "completion" AST. This is called in several cases:
  *

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 03/17] staging: lustre: LNET excludes USERIO
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

LNET_MINOR and USERIO_MINOR are the same value, so
they cannot both be used in the same kernel.
Until this is resolved, don't allow them to be built
together.  This saves automatic testing from noticing this
known problem.

Reported-by: kernel test robot <fengguang.wu@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lnet/Kconfig |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/Kconfig b/drivers/staging/lustre/lnet/Kconfig
index ad049e6f24e4..fe4b24acf075 100644
--- a/drivers/staging/lustre/lnet/Kconfig
+++ b/drivers/staging/lustre/lnet/Kconfig
@@ -1,6 +1,6 @@
 config LNET
 	tristate "Lustre networking subsystem (LNet)"
-	depends on INET
+	depends on INET && !USERIO
 	help
 	  The Lustre network layer, also known as LNet, is a networking abstaction
 	  level API that was initially created to allow Lustre Filesystem to utilize

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 01/17] staging: lustre: remove invariant in cl_io_read_ahead()
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

This invariant can fail as ci_type is somtimes CIS_INIT.

According to Jinshan Xiong, or of the most recent significant
change to this code, "We should get rid of it."

So do that.

Fixes: 1e1db2a97be5 ("staging: lustre: clio: Revise read ahead implementation")
Cc: Jinshan Xiong <jinshan.xiong@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/obdclass/cl_io.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c
index ab84e011b560..fcdae6029258 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
@@ -599,7 +599,6 @@ int cl_io_read_ahead(const struct lu_env *env, struct cl_io *io,
 	int		       result = 0;
 
 	LINVRNT(io->ci_type == CIT_READ || io->ci_type == CIT_FAULT);
-	LINVRNT(io->ci_state == CIS_IO_GOING || io->ci_state == CIS_LOCKED);
 	LINVRNT(cl_io_invariant(io));
 
 	cl_io_for_each(scan, io) {

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 04/17] staging: lustre: remove unused hash tables.
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

exp_lock_hash and exp_flock_hash are unused in
the client, so remove all references.

Also remove unused hashtable size definitions.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |   10 -------
 .../staging/lustre/lustre/include/lustre_export.h  |    7 -----
 .../staging/lustre/lustre/include/obd_support.h    |   18 -------------
 drivers/staging/lustre/lustre/ldlm/ldlm_flock.c    |   11 +-------
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   14 ----------
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   27 +-------------------
 drivers/staging/lustre/lustre/obdclass/genops.c    |    2 -
 7 files changed, 3 insertions(+), 86 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 7407acf60cf8..5a355fbab401 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -629,16 +629,6 @@ struct ldlm_lock {
 	 * Tree node for ldlm_extent.
 	 */
 	struct ldlm_interval	*l_tree_node;
-	/**
-	 * Per export hash of locks.
-	 * Protected by per-bucket exp->exp_lock_hash locks.
-	 */
-	struct hlist_node	l_exp_hash;
-	/**
-	 * Per export hash of flock locks.
-	 * Protected by per-bucket exp->exp_flock_hash locks.
-	 */
-	struct hlist_node	l_exp_flock_hash;
 	/**
 	 * Requested mode.
 	 * Protected by lr_lock.
diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h
index 40cd168ed2ea..19ce13bc8ee6 100644
--- a/drivers/staging/lustre/lustre/include/lustre_export.h
+++ b/drivers/staging/lustre/lustre/include/lustre_export.h
@@ -102,13 +102,6 @@ struct obd_export {
 	struct ptlrpc_connection *exp_connection;
 	/** Connection count value from last successful reconnect rpc */
 	__u32		     exp_conn_cnt;
-	/** Hash list of all ldlm locks granted on this export */
-	struct cfs_hash	       *exp_lock_hash;
-	/**
-	 * Hash list for Posix lock deadlock detection, added with
-	 * ldlm_lock::l_exp_flock_hash.
-	 */
-	struct cfs_hash	       *exp_flock_hash;
 	struct list_head		exp_outstanding_replies;
 	struct list_head		exp_uncommitted_replies;
 	spinlock_t		  exp_uncommitted_replies_lock;
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
index 8595091b8b86..eb2d6cb6b40b 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -67,27 +67,9 @@ extern char obd_jobid_var[];
 #define HASH_UUID_BKT_BITS 5
 #define HASH_UUID_CUR_BITS 7
 #define HASH_UUID_MAX_BITS 12
-#define HASH_NID_BKT_BITS 5
-#define HASH_NID_CUR_BITS 7
-#define HASH_NID_MAX_BITS 12
-#define HASH_NID_STATS_BKT_BITS 5
-#define HASH_NID_STATS_CUR_BITS 7
-#define HASH_NID_STATS_MAX_BITS 12
-#define HASH_LQE_BKT_BITS 5
-#define HASH_LQE_CUR_BITS 7
-#define HASH_LQE_MAX_BITS 12
 #define HASH_CONN_BKT_BITS 5
 #define HASH_CONN_CUR_BITS 5
 #define HASH_CONN_MAX_BITS 15
-#define HASH_EXP_LOCK_BKT_BITS  5
-#define HASH_EXP_LOCK_CUR_BITS  7
-#define HASH_EXP_LOCK_MAX_BITS  16
-#define HASH_CL_ENV_BKT_BITS    5
-#define HASH_CL_ENV_BITS	10
-#define HASH_JOB_STATS_BKT_BITS 5
-#define HASH_JOB_STATS_CUR_BITS 7
-#define HASH_JOB_STATS_MAX_BITS 12
-
 /* Timeout definitions */
 #define OBD_TIMEOUT_DEFAULT	     100
 /* Time to wait for all clients to reconnect during recovery (hard limit) */
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
index 411b540b96d9..94f3b1e49896 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
@@ -83,9 +83,6 @@ ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode)
 	LDLM_DEBUG(lock, "%s(mode: %d)",
 		   __func__, mode);
 
-	/* Safe to not lock here, since it should be empty anyway */
-	LASSERT(hlist_unhashed(&lock->l_exp_flock_hash));
-
 	list_del_init(&lock->l_res_link);
 
 	/* client side - set a flag to prevent sending a CANCEL */
@@ -263,15 +260,9 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req)
 		lock->l_policy_data.l_flock.start =
 			new->l_policy_data.l_flock.end + 1;
 		new2->l_conn_export = lock->l_conn_export;
-		if (lock->l_export) {
+		if (lock->l_export)
 			new2->l_export = class_export_lock_get(lock->l_export,
 							       new2);
-			if (new2->l_export->exp_lock_hash &&
-			    hlist_unhashed(&new2->l_exp_hash))
-				cfs_hash_add(new2->l_export->exp_lock_hash,
-					     &new2->l_remote_handle,
-					     &new2->l_exp_hash);
-		}
 		ldlm_lock_addref_internal_nolock(new2,
 						 lock->l_granted_mode);
 
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 95bea351d21d..b8fd778d9832 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -318,18 +318,6 @@ static int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
 	}
 	ldlm_set_destroyed(lock);
 
-	if (lock->l_export && lock->l_export->exp_lock_hash) {
-		/* NB: it's safe to call cfs_hash_del() even lock isn't
-		 * in exp_lock_hash.
-		 */
-		/* In the function below, .hs_keycmp resolves to
-		 * ldlm_export_lock_keycmp()
-		 */
-		/* coverity[overrun-buffer-val] */
-		cfs_hash_del(lock->l_export->exp_lock_hash,
-			     &lock->l_remote_handle, &lock->l_exp_hash);
-	}
-
 	ldlm_lock_remove_from_lru(lock);
 	class_handle_unhash(&lock->l_handle);
 
@@ -419,8 +407,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
 	lock->l_blocking_lock = NULL;
 	INIT_LIST_HEAD(&lock->l_sl_mode);
 	INIT_LIST_HEAD(&lock->l_sl_policy);
-	INIT_HLIST_NODE(&lock->l_exp_hash);
-	INIT_HLIST_NODE(&lock->l_exp_flock_hash);
 
 	lprocfs_counter_incr(ldlm_res_to_ns(resource)->ns_stats,
 			     LDLM_NSS_LOCKS);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index be43958e4090..8e79f5e073ff 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -405,19 +405,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
 	cleanup_phase = 0;
 
 	lock_res_and_lock(lock);
-	/* Key change rehash lock in per-export hash with new key */
-	if (exp->exp_lock_hash) {
-		/* In the function below, .hs_keycmp resolves to
-		 * ldlm_export_lock_keycmp()
-		 */
-		/* coverity[overrun-buffer-val] */
-		cfs_hash_rehash_key(exp->exp_lock_hash,
-				    &lock->l_remote_handle,
-				    &reply->lock_handle,
-				    &lock->l_exp_hash);
-	} else {
-		lock->l_remote_handle = reply->lock_handle;
-	}
+	lock->l_remote_handle = reply->lock_handle;
 
 	*flags = ldlm_flags_from_wire(reply->lock_flags);
 	lock->l_flags |= ldlm_flags_from_wire(reply->lock_flags &
@@ -1884,18 +1872,7 @@ static int replay_lock_interpret(const struct lu_env *env,
 
 	/* Key change rehash lock in per-export hash with new key */
 	exp = req->rq_export;
-	if (exp && exp->exp_lock_hash) {
-		/* In the function below, .hs_keycmp resolves to
-		 * ldlm_export_lock_keycmp()
-		 */
-		/* coverity[overrun-buffer-val] */
-		cfs_hash_rehash_key(exp->exp_lock_hash,
-				    &lock->l_remote_handle,
-				    &reply->lock_handle,
-				    &lock->l_exp_hash);
-	} else {
-		lock->l_remote_handle = reply->lock_handle;
-	}
+	lock->l_remote_handle = reply->lock_handle;
 
 	LDLM_DEBUG(lock, "replayed lock:");
 	ptlrpc_import_recovery_state_machine(req->rq_import);
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 63ccbabb4c5a..86e22472719a 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -721,8 +721,6 @@ struct obd_export *class_new_export(struct obd_device *obd,
 		return ERR_PTR(-ENOMEM);
 
 	export->exp_conn_cnt = 0;
-	export->exp_lock_hash = NULL;
-	export->exp_flock_hash = NULL;
 	atomic_set(&export->exp_refcount, 2);
 	atomic_set(&export->exp_rpc_count, 0);
 	atomic_set(&export->exp_cb_count, 0);

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 05/17] staging: lustre: remove unneeded include.
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

cfs_hash usage was removed from cl_object.c
some time ago, so remove the #include as well.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/obdclass/cl_object.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index 7809f6ae1809..f1641645acae 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -53,7 +53,6 @@
 #include <obd_support.h>
 #include <lustre_fid.h>
 #include <linux/list.h>
-#include <linux/libcfs/libcfs_hash.h>	/* for cfs_hash stuff */
 #include <cl_object.h>
 #include <lu_object.h>
 #include "cl_internal.h"

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 06/17] staging: lustre: tidy up ldlm_resource_putref()
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

1/ the return value of ldlm_resource_putref() is never
  used, so change it to return 'void'.
2/ Move all of the code to run on the last putref to
   __ldlm_resource_putref_final().  This means a lock
   is taken in one function and dropped in another, but
   that isn't too uncommon, and will disappear in a future
   patch.
   Now that the code it together, it becomes apparent that
   we are dropping a ref on the namespace *before* the last
   use.  So keep the ref until after.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_dlm.h |    2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   21 +++++++++-----------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index 5a355fbab401..d668d86423a4 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -1190,7 +1190,7 @@ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
 					struct ldlm_resource *parent,
 					const struct ldlm_res_id *,
 					enum ldlm_type type, int create);
-int ldlm_resource_putref(struct ldlm_resource *res);
+void ldlm_resource_putref(struct ldlm_resource *res);
 void ldlm_resource_add_lock(struct ldlm_resource *res,
 			    struct list_head *head,
 			    struct ldlm_lock *lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 4c44603ab6f9..8841a1bb2c0a 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1195,6 +1195,7 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
 					 struct ldlm_resource *res)
 {
 	struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
+	struct ldlm_namespace *ns = nsb->nsb_namespace;
 
 	if (!list_empty(&res->lr_granted)) {
 		ldlm_resource_dump(D_ERROR, res);
@@ -1206,15 +1207,18 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
 		LBUG();
 	}
 
-	cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash,
+	cfs_hash_bd_del_locked(ns->ns_rs_hash,
 			       bd, &res->lr_hash);
 	lu_ref_fini(&res->lr_reference);
+	cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1);
+	if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
+		ns->ns_lvbo->lvbo_free(res);
 	if (cfs_hash_bd_count_get(bd) == 0)
-		ldlm_namespace_put(nsb->nsb_namespace);
+		ldlm_namespace_put(ns);
+	kmem_cache_free(ldlm_resource_slab, res);
 }
 
-/* Returns 1 if the resource was freed, 0 if it remains. */
-int ldlm_resource_putref(struct ldlm_resource *res)
+void ldlm_resource_putref(struct ldlm_resource *res)
 {
 	struct ldlm_namespace *ns = ldlm_res_to_ns(res);
 	struct cfs_hash_bd   bd;
@@ -1224,15 +1228,8 @@ int ldlm_resource_putref(struct ldlm_resource *res)
 	       res, atomic_read(&res->lr_refcount) - 1);
 
 	cfs_hash_bd_get(ns->ns_rs_hash, &res->lr_name, &bd);
-	if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) {
+	if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount))
 		__ldlm_resource_putref_final(&bd, res);
-		cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
-		if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
-			ns->ns_lvbo->lvbo_free(res);
-		kmem_cache_free(ldlm_resource_slab, res);
-		return 1;
-	}
-	return 0;
 }
 EXPORT_SYMBOL(ldlm_resource_putref);
 

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 08/17] staging: lustre: add container_of_safe()
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

Luster has a container_of0() function which is similar to
container_of() but passes an IS_ERR_OR_NULL() pointer through
unchanged.
This could be generally useful: bcache at last has a similar function.

Naming is hard, but the precedent set by hlist_entry_safe() suggests
a _safe suffix might be most consistent.

So add container_of_safe() to kernel.h, and replace all occurrences of
container_of0() with one of
  - list_first_entry, list_next_entry, when that is a better fit,
  - container_of(), when the pointer is used as a validpointer in
    surrounding code,
  - container_of_safe() when there is no obviously better alternative.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   11 -----------
 drivers/staging/lustre/lustre/include/cl_object.h  |   10 +++++-----
 drivers/staging/lustre/lustre/include/lu_object.h  |    6 +++---
 drivers/staging/lustre/lustre/llite/llite_nfs.c    |    2 +-
 drivers/staging/lustre/lustre/llite/vvp_internal.h |    8 ++++----
 drivers/staging/lustre/lustre/lmv/lmv_internal.h   |    2 +-
 .../staging/lustre/lustre/lov/lov_cl_internal.h    |   18 +++++++++---------
 drivers/staging/lustre/lustre/lov/lov_internal.h   |    2 +-
 drivers/staging/lustre/lustre/obdclass/lu_object.c |    8 ++++----
 .../staging/lustre/lustre/obdecho/echo_client.c    |    2 +-
 .../staging/lustre/lustre/osc/osc_cl_internal.h    |   10 +++++-----
 drivers/staging/lustre/lustre/osc/osc_internal.h   |    2 +-
 drivers/staging/lustre/lustre/osc/osc_io.c         |    2 +-
 drivers/staging/lustre/lustre/osc/osc_object.c     |    2 +-
 include/linux/kernel.h                             |   16 ++++++++++++++++
 15 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 392793582956..3b751c436b3d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -99,17 +99,6 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
 int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
 int libcfs_ioctl(unsigned long cmd, void __user *arg);
 
-/* container_of depends on "likely" which is defined in libcfs_private.h */
-static inline void *__container_of(void *ptr, unsigned long shift)
-{
-	if (IS_ERR_OR_NULL(ptr))
-		return ptr;
-	return (char *)ptr - shift;
-}
-
-#define container_of0(ptr, type, member) \
-	((type *)__container_of((void *)(ptr), offsetof(type, member)))
-
 #define _LIBCFS_H
 
 extern struct miscdevice libcfs_dev;
diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
index 341a145c3331..6f7b991be809 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -1941,7 +1941,7 @@ static inline int lu_device_is_cl(const struct lu_device *d)
 static inline struct cl_device *lu2cl_dev(const struct lu_device *d)
 {
 	LASSERT(!d || IS_ERR(d) || lu_device_is_cl(d));
-	return container_of0(d, struct cl_device, cd_lu_dev);
+	return container_of_safe(d, struct cl_device, cd_lu_dev);
 }
 
 static inline struct lu_device *cl2lu_dev(struct cl_device *d)
@@ -1952,13 +1952,13 @@ static inline struct lu_device *cl2lu_dev(struct cl_device *d)
 static inline struct cl_object *lu2cl(const struct lu_object *o)
 {
 	LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->lo_dev));
-	return container_of0(o, struct cl_object, co_lu);
+	return container_of_safe(o, struct cl_object, co_lu);
 }
 
 static inline const struct cl_object_conf *
 lu2cl_conf(const struct lu_object_conf *conf)
 {
-	return container_of0(conf, struct cl_object_conf, coc_lu);
+	return container_of_safe(conf, struct cl_object_conf, coc_lu);
 }
 
 static inline struct cl_object *cl_object_next(const struct cl_object *obj)
@@ -1969,12 +1969,12 @@ static inline struct cl_object *cl_object_next(const struct cl_object *obj)
 static inline struct cl_device *cl_object_device(const struct cl_object *o)
 {
 	LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev));
-	return container_of0(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
+	return container_of_safe(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
 }
 
 static inline struct cl_object_header *luh2coh(const struct lu_object_header *h)
 {
-	return container_of0(h, struct cl_object_header, coh_lu);
+	return container_of_safe(h, struct cl_object_header, coh_lu);
 }
 
 static inline struct cl_site *cl_object_site(const struct cl_object *obj)
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
index 35c7b582f36d..c3b0ed518819 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -745,15 +745,15 @@ struct lu_object *lu_object_find_slice(const struct lu_env *env,
 static inline struct lu_object *lu_object_top(struct lu_object_header *h)
 {
 	LASSERT(!list_empty(&h->loh_layers));
-	return container_of0(h->loh_layers.next, struct lu_object, lo_linkage);
+	return list_first_entry(&h->loh_layers, struct lu_object, lo_linkage);
 }
 
 /**
  * Next sub-object in the layering
  */
-static inline struct lu_object *lu_object_next(const struct lu_object *o)
+static inline const struct lu_object *lu_object_next(const struct lu_object *o)
 {
-	return container_of0(o->lo_linkage.next, struct lu_object, lo_linkage);
+	return list_next_entry(o, lo_linkage);
 }
 
 /**
diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c
index a6a1d80c711a..14172688d55f 100644
--- a/drivers/staging/lustre/lustre/llite/llite_nfs.c
+++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c
@@ -223,7 +223,7 @@ static int ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name,
 	/* It is hack to access lde_fid for comparison with lgd_fid.
 	 * So the input 'name' must be part of the 'lu_dirent'.
 	 */
-	struct lu_dirent *lde = container_of0(name, struct lu_dirent, lde_name);
+	struct lu_dirent *lde = container_of((void*)name, struct lu_dirent, lde_name);
 	struct ll_getname_data *lgd =
 		container_of(ctx, struct ll_getname_data, ctx);
 	struct lu_fid fid;
diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h
index 02ea5161d635..7d3abb43584a 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_internal.h
+++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h
@@ -263,22 +263,22 @@ static inline struct lu_device *vvp2lu_dev(struct vvp_device *vdv)
 
 static inline struct vvp_device *lu2vvp_dev(const struct lu_device *d)
 {
-	return container_of0(d, struct vvp_device, vdv_cl.cd_lu_dev);
+	return container_of_safe(d, struct vvp_device, vdv_cl.cd_lu_dev);
 }
 
 static inline struct vvp_device *cl2vvp_dev(const struct cl_device *d)
 {
-	return container_of0(d, struct vvp_device, vdv_cl);
+	return container_of_safe(d, struct vvp_device, vdv_cl);
 }
 
 static inline struct vvp_object *cl2vvp(const struct cl_object *obj)
 {
-	return container_of0(obj, struct vvp_object, vob_cl);
+	return container_of_safe(obj, struct vvp_object, vob_cl);
 }
 
 static inline struct vvp_object *lu2vvp(const struct lu_object *obj)
 {
-	return container_of0(obj, struct vvp_object, vob_cl.co_lu);
+	return container_of_safe(obj, struct vvp_object, vob_cl.co_lu);
 }
 
 static inline struct inode *vvp_object_inode(const struct cl_object *obj)
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
index c27c3c32188d..68a99170c424 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h
+++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
@@ -60,7 +60,7 @@ int lmv_revalidate_slaves(struct obd_export *exp,
 
 static inline struct obd_device *lmv2obd_dev(struct lmv_obd *lmv)
 {
-	return container_of0(lmv, struct obd_device, u.lmv);
+	return container_of_safe(lmv, struct obd_device, u.lmv);
 }
 
 static inline struct lmv_tgt_desc *
diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
index 1185eceaf497..2e9c75ebdda5 100644
--- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
@@ -496,7 +496,7 @@ static inline struct lu_device *lov2lu_dev(struct lov_device *lov)
 static inline struct lov_device *lu2lov_dev(const struct lu_device *d)
 {
 	LINVRNT(d->ld_type == &lov_device_type);
-	return container_of0(d, struct lov_device, ld_cl.cd_lu_dev);
+	return container_of(d, struct lov_device, ld_cl.cd_lu_dev);
 }
 
 static inline struct cl_device *lovsub2cl_dev(struct lovsub_device *lovsub)
@@ -512,13 +512,13 @@ static inline struct lu_device *lovsub2lu_dev(struct lovsub_device *lovsub)
 static inline struct lovsub_device *lu2lovsub_dev(const struct lu_device *d)
 {
 	LINVRNT(d->ld_type == &lovsub_device_type);
-	return container_of0(d, struct lovsub_device, acid_cl.cd_lu_dev);
+	return container_of(d, struct lovsub_device, acid_cl.cd_lu_dev);
 }
 
 static inline struct lovsub_device *cl2lovsub_dev(const struct cl_device *d)
 {
 	LINVRNT(d->cd_lu_dev.ld_type == &lovsub_device_type);
-	return container_of0(d, struct lovsub_device, acid_cl);
+	return container_of(d, struct lovsub_device, acid_cl);
 }
 
 static inline struct lu_object *lov2lu(struct lov_object *lov)
@@ -534,13 +534,13 @@ static inline struct cl_object *lov2cl(struct lov_object *lov)
 static inline struct lov_object *lu2lov(const struct lu_object *obj)
 {
 	LINVRNT(lov_is_object(obj));
-	return container_of0(obj, struct lov_object, lo_cl.co_lu);
+	return container_of(obj, struct lov_object, lo_cl.co_lu);
 }
 
 static inline struct lov_object *cl2lov(const struct cl_object *obj)
 {
 	LINVRNT(lov_is_object(&obj->co_lu));
-	return container_of0(obj, struct lov_object, lo_cl);
+	return container_of(obj, struct lov_object, lo_cl);
 }
 
 static inline struct lu_object *lovsub2lu(struct lovsub_object *los)
@@ -556,13 +556,13 @@ static inline struct cl_object *lovsub2cl(struct lovsub_object *los)
 static inline struct lovsub_object *cl2lovsub(const struct cl_object *obj)
 {
 	LINVRNT(lovsub_is_object(&obj->co_lu));
-	return container_of0(obj, struct lovsub_object, lso_cl);
+	return container_of(obj, struct lovsub_object, lso_cl);
 }
 
 static inline struct lovsub_object *lu2lovsub(const struct lu_object *obj)
 {
 	LINVRNT(lovsub_is_object(obj));
-	return container_of0(obj, struct lovsub_object, lso_cl.co_lu);
+	return container_of(obj, struct lovsub_object, lso_cl.co_lu);
 }
 
 static inline struct lovsub_lock *
@@ -590,14 +590,14 @@ static inline struct lov_lock *cl2lov_lock(const struct cl_lock_slice *slice)
 static inline struct lov_page *cl2lov_page(const struct cl_page_slice *slice)
 {
 	LINVRNT(lov_is_object(&slice->cpl_obj->co_lu));
-	return container_of0(slice, struct lov_page, lps_cl);
+	return container_of(slice, struct lov_page, lps_cl);
 }
 
 static inline struct lovsub_page *
 cl2lovsub_page(const struct cl_page_slice *slice)
 {
 	LINVRNT(lovsub_is_object(&slice->cpl_obj->co_lu));
-	return container_of0(slice, struct lovsub_page, lsb_cl);
+	return container_of(slice, struct lovsub_page, lsb_cl);
 }
 
 static inline struct lov_io *cl2lov_io(const struct lu_env *env,
diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h
index a56d71c2dda2..27f60dd7ab9a 100644
--- a/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -277,7 +277,7 @@ static inline bool lov_oinfo_is_dummy(const struct lov_oinfo *loi)
 
 static inline struct obd_device *lov2obd(const struct lov_obd *lov)
 {
-	return container_of0(lov, struct obd_device, u.lov);
+	return container_of_safe(lov, struct obd_device, u.lov);
 }
 
 #endif
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 8ddf23b82a2c..6db5d95d4b36 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -319,7 +319,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o)
 		 * lives as long as possible and ->loo_object_free() methods
 		 * can look at its contents.
 		 */
-		o = container_of0(splice.prev, struct lu_object, lo_linkage);
+		o = container_of(splice.prev, struct lu_object, lo_linkage);
 		list_del_init(&o->lo_linkage);
 		o->lo_ops->loo_object_free(env, o);
 	}
@@ -404,8 +404,8 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s,
 		 * races due to the reasons described in lu_object_put().
 		 */
 		while (!list_empty(&dispose)) {
-			h = container_of0(dispose.next,
-					  struct lu_object_header, loh_lru);
+			h = container_of(dispose.next,
+					 struct lu_object_header, loh_lru);
 			list_del_init(&h->loh_lru);
 			lu_object_free(env, lu_object_top(h));
 			lprocfs_counter_incr(s->ls_stats, LU_SS_LRU_PURGED);
@@ -579,7 +579,7 @@ static struct lu_object *htable_lookup(struct lu_site *s,
 		return ERR_PTR(-ENOENT);
 	}
 
-	h = container_of0(hnode, struct lu_object_header, loh_hash);
+	h = container_of(hnode, struct lu_object_header, loh_hash);
 	if (likely(!lu_object_is_dying(h))) {
 		cfs_hash_get(s->ls_obj_hash, hnode);
 		lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index 99a76db51ae0..767067b61109 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -99,7 +99,7 @@ static int echo_client_cleanup(struct obd_device *obddev);
  */
 static inline struct echo_device *cl2echo_dev(const struct cl_device *dev)
 {
-	return container_of0(dev, struct echo_device, ed_cl);
+	return container_of_safe(dev, struct echo_device, ed_cl);
 }
 
 static inline struct cl_device *echo_dev2cl(struct echo_device *d)
diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
index 1449013722f6..dc25dd12d7d5 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
@@ -460,7 +460,7 @@ static inline int osc_is_object(const struct lu_object *obj)
 static inline struct osc_device *lu2osc_dev(const struct lu_device *d)
 {
 	LINVRNT(d->ld_type == &osc_device_type);
-	return container_of0(d, struct osc_device, od_cl.cd_lu_dev);
+	return container_of(d, struct osc_device, od_cl.cd_lu_dev);
 }
 
 static inline struct obd_export *osc_export(const struct osc_object *obj)
@@ -476,7 +476,7 @@ static inline struct client_obd *osc_cli(const struct osc_object *obj)
 static inline struct osc_object *cl2osc(const struct cl_object *obj)
 {
 	LINVRNT(osc_is_object(&obj->co_lu));
-	return container_of0(obj, struct osc_object, oo_cl);
+	return container_of(obj, struct osc_object, oo_cl);
 }
 
 static inline struct cl_object *osc2cl(const struct osc_object *obj)
@@ -509,12 +509,12 @@ static inline enum cl_lock_mode osc_ldlm2cl_lock(enum ldlm_mode mode)
 static inline struct osc_page *cl2osc_page(const struct cl_page_slice *slice)
 {
 	LINVRNT(osc_is_object(&slice->cpl_obj->co_lu));
-	return container_of0(slice, struct osc_page, ops_cl);
+	return container_of(slice, struct osc_page, ops_cl);
 }
 
 static inline struct osc_page *oap2osc(struct osc_async_page *oap)
 {
-	return container_of0(oap, struct osc_page, ops_oap);
+	return container_of_safe(oap, struct osc_page, ops_oap);
 }
 
 static inline pgoff_t osc_index(struct osc_page *opg)
@@ -545,7 +545,7 @@ osc_cl_page_osc(struct cl_page *page, struct osc_object *osc)
 static inline struct osc_lock *cl2osc_lock(const struct cl_lock_slice *slice)
 {
 	LINVRNT(osc_is_object(&slice->cls_obj->co_lu));
-	return container_of0(slice, struct osc_lock, ols_cl);
+	return container_of(slice, struct osc_lock, ols_cl);
 }
 
 static inline struct osc_lock *osc_lock_at(const struct cl_lock *lock)
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h
index 32db150fd42e..be8c7829b3de 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -180,7 +180,7 @@ struct osc_device {
 
 static inline struct osc_device *obd2osc_dev(const struct obd_device *d)
 {
-	return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
+	return container_of_safe(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
 }
 
 extern struct lu_kmem_descr osc_caches[];
diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c
index 76743faf3e6d..67734a8ed331 100644
--- a/drivers/staging/lustre/lustre/osc/osc_io.c
+++ b/drivers/staging/lustre/lustre/osc/osc_io.c
@@ -55,7 +55,7 @@
 static struct osc_io *cl2osc_io(const struct lu_env *env,
 				const struct cl_io_slice *slice)
 {
-	struct osc_io *oio = container_of0(slice, struct osc_io, oi_cl);
+	struct osc_io *oio = container_of_safe(slice, struct osc_io, oi_cl);
 
 	LINVRNT(oio == osc_env_io(env));
 	return oio;
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index 6baa8e2e00c9..9582d5a642e2 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -58,7 +58,7 @@ static struct lu_object *osc2lu(struct osc_object *osc)
 static struct osc_object *lu2osc(const struct lu_object *obj)
 {
 	LINVRNT(osc_is_object(obj));
-	return container_of0(obj, struct osc_object, oo_cl.co_lu);
+	return container_of(obj, struct osc_object, oo_cl.co_lu);
 }
 
 /*****************************************************************************
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2da80e079d56..e5e991642d8f 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -941,6 +941,22 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
 			 "pointer type mismatch in container_of()");	\
 	((type *)(__mptr - offsetof(type, member))); })
 
+/**
+ * container_of_safe - cast a member of a structure out to the containing structure
+ * @ptr:	the pointer to the member.
+ * @type:	the type of the container struct this is embedded in.
+ * @member:	the name of the member within the struct.
+ *
+ * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged.
+ */
+#define container_of_safe(ptr, type, member) ({				\
+	void *__mptr = (void *)(ptr);					\
+	BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&	\
+			 !__same_type(*(ptr), void),			\
+			 "pointer type mismatch in container_of()");	\
+	IS_ERR_OR_NULL(ptr) ? ERR_CAST(ptr) :				\
+		((type *)(__mptr - offsetof(type, member))); })
+
 /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 09/17] staging: lustre: cfs_time_current() -> jiffies.
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

Discard cfs_time_current() and cfs_time_current64()
and use jiffies and get_jiffies_64() like the rest of the kernel.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/include/linux/libcfs/libcfs_time.h      |    2 -
 .../lustre/include/linux/libcfs/linux/linux-time.h |    9 ----
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   14 +++---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    8 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    9 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   44 ++++++++++----------
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |    6 +--
 drivers/staging/lustre/lnet/lnet/lib-move.c        |    4 +-
 drivers/staging/lustre/lnet/lnet/net_fault.c       |    6 +--
 drivers/staging/lustre/lnet/lnet/peer.c            |    2 -
 drivers/staging/lustre/lnet/lnet/router.c          |    6 +--
 drivers/staging/lustre/lnet/lnet/router_proc.c     |    4 +-
 drivers/staging/lustre/lnet/selftest/conrpc.c      |    6 +--
 drivers/staging/lustre/lnet/selftest/console.c     |    4 +-
 drivers/staging/lustre/lnet/selftest/framework.c   |    2 -
 drivers/staging/lustre/lustre/include/lustre_net.h |    2 -
 drivers/staging/lustre/lustre/include/obd_class.h  |    6 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |    2 -
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    2 -
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   10 ++---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 -
 .../staging/lustre/lustre/llite/llite_internal.h   |    2 -
 drivers/staging/lustre/lustre/llite/statahead.c    |    2 -
 drivers/staging/lustre/lustre/lov/lov_request.c    |    4 +-
 drivers/staging/lustre/lustre/osc/osc_cache.c      |    2 -
 drivers/staging/lustre/lustre/osc/osc_object.c     |    4 +-
 drivers/staging/lustre/lustre/osc/osc_page.c       |    4 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    |    2 -
 drivers/staging/lustre/lustre/ptlrpc/client.c      |    4 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c      |    2 -
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    4 +-
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    4 +-
 32 files changed, 88 insertions(+), 96 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index c4f25be78268..df7a3f13f3b3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -62,7 +62,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
 
 static inline unsigned long cfs_time_shift(int seconds)
 {
-	return cfs_time_add(cfs_time_current(), seconds * HZ);
+	return cfs_time_add(jiffies, seconds * HZ);
 }
 
 /*
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 805cb326af86..ba115e8c820f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -60,18 +60,11 @@
  * Generic kernel stuff
  */
 
-static inline unsigned long cfs_time_current(void)
-{
-	return jiffies;
-}
-
 static inline long cfs_duration_sec(long d)
 {
 	return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-#define cfs_time_current_64 get_jiffies_64
-
 static inline u64 cfs_time_add_64(u64 t, u64 d)
 {
 	return t + d;
@@ -79,7 +72,7 @@ static inline u64 cfs_time_add_64(u64 t, u64 d)
 
 static inline u64 cfs_time_shift_64(int seconds)
 {
-	return cfs_time_add_64(cfs_time_current_64(),
+	return cfs_time_add_64(get_jiffies_64(),
 			       seconds * HZ);
 }
 
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 7ae2955c4db6..7df07f39b849 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1043,7 +1043,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,
 			 unsigned long *when)
 {
 	unsigned long last_alive = 0;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	rwlock_t *glock = &kiblnd_data.kib_global_lock;
 	struct kib_peer *peer;
 	unsigned long flags;
@@ -1552,7 +1552,7 @@ void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int status)
 	LIST_HEAD(zombies);
 	struct kib_fmr_pool *fpo = fmr->fmr_pool;
 	struct kib_fmr_poolset *fps;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	struct kib_fmr_pool *tmp;
 	int rc;
 
@@ -1726,7 +1726,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
 		goto again;
 	}
 
-	if (time_before(cfs_time_current(), fps->fps_next_retry)) {
+	if (time_before(jiffies, fps->fps_next_retry)) {
 		/* someone failed recently */
 		spin_unlock(&fps->fps_lock);
 		return -EAGAIN;
@@ -1858,7 +1858,7 @@ void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
 	LIST_HEAD(zombies);
 	struct kib_poolset *ps = pool->po_owner;
 	struct kib_pool *tmp;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 
 	spin_lock(&ps->ps_lock);
 
@@ -1927,7 +1927,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
 		goto again;
 	}
 
-	if (time_before(cfs_time_current(), ps->ps_next_retry)) {
+	if (time_before(jiffies, ps->ps_next_retry)) {
 		/* someone failed recently */
 		spin_unlock(&ps->ps_lock);
 		return NULL;
@@ -1937,10 +1937,10 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
 	spin_unlock(&ps->ps_lock);
 
 	CDEBUG(D_NET, "%s pool exhausted, allocate new pool\n", ps->ps_name);
-	time_before = cfs_time_current();
+	time_before = jiffies;
 	rc = ps->ps_pool_create(ps, ps->ps_pool_size, &pool);
 	CDEBUG(D_NET, "ps_pool_create took %lu HZ to complete",
-	       cfs_time_current() - time_before);
+	       jiffies - time_before);
 
 	spin_lock(&ps->ps_lock);
 	ps->ps_increasing = 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 6690a6cd4e34..c1c3277f4c1f 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1853,8 +1853,8 @@ kiblnd_thread_fini(void)
 static void
 kiblnd_peer_alive(struct kib_peer *peer)
 {
-	/* This is racy, but everyone's only writing cfs_time_current() */
-	peer->ibp_last_alive = cfs_time_current();
+	/* This is racy, but everyone's only writing jiffies */
+	peer->ibp_last_alive = jiffies;
 	mb();
 }
 
@@ -3206,7 +3206,7 @@ kiblnd_check_conns(int idx)
 			if (timedout) {
 				CERROR("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n",
 				       libcfs_nid2str(peer->ibp_nid),
-				       cfs_duration_sec(cfs_time_current() -
+				       cfs_duration_sec(jiffies -
 							peer->ibp_last_alive),
 				       conn->ibc_credits,
 				       conn->ibc_outstanding_credits,
@@ -3681,7 +3681,7 @@ kiblnd_failover_thread(void *arg)
 
 		list_for_each_entry(dev, &kiblnd_data.kib_failed_devs,
 				    ibd_fail_list) {
-			if (time_before(cfs_time_current(),
+			if (time_before(jiffies,
 					dev->ibd_next_failover))
 				continue;
 			do_failover = 1;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 7086678e1c3e..0efde0009a15 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1276,7 +1276,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
 	}
 
 	conn->ksnc_peer = peer;		 /* conn takes my ref on peer */
-	peer->ksnp_last_alive = cfs_time_current();
+	peer->ksnp_last_alive = jiffies;
 	peer->ksnp_send_keepalive = 0;
 	peer->ksnp_error = 0;
 
@@ -1284,7 +1284,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
 	sched->kss_nconns++;
 	conn->ksnc_scheduler = sched;
 
-	conn->ksnc_tx_last_post = cfs_time_current();
+	conn->ksnc_tx_last_post = jiffies;
 	/* Set the deadline for the outgoing HELLO to drain */
 	conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
 	conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
@@ -1682,8 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
 		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
 		       &conn->ksnc_ipaddr, conn->ksnc_port,
 		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
-		       cfs_duration_sec(cfs_time_sub(cfs_time_current(),
-						     last_rcv)));
+		       cfs_duration_sec(cfs_time_sub(jiffies, last_rcv)));
 		lnet_finalize(conn->ksnc_peer->ksnp_ni,
 			      conn->ksnc_cookie, -EIO);
 		break;
@@ -1832,7 +1831,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
 {
 	int connect = 1;
 	unsigned long last_alive = 0;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	struct ksock_peer *peer = NULL;
 	rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
 	struct lnet_process_id id = {
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 036fecbcede8..f97da4540b51 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -222,7 +222,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 			 */
 			conn->ksnc_tx_deadline =
 				cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
-			conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
+			conn->ksnc_peer->ksnp_last_alive = jiffies;
 			conn->ksnc_tx_bufnob = bufnob;
 			mb();
 		}
@@ -267,7 +267,7 @@ ksocknal_recv_iter(struct ksock_conn *conn)
 	/* received something... */
 	nob = rc;
 
-	conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
+	conn->ksnc_peer->ksnp_last_alive = jiffies;
 	conn->ksnc_rx_deadline =
 		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
 	mb();		       /* order with setting rx_started */
@@ -481,7 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 		LASSERT(conn->ksnc_tx_scheduled);
 		list_add_tail(&conn->ksnc_tx_list,
 			      &ksocknal_data.ksnd_enomem_conns);
-		if (!cfs_time_aftereq(cfs_time_add(cfs_time_current(),
+		if (!cfs_time_aftereq(cfs_time_add(jiffies,
 						   SOCKNAL_ENOMEM_RETRY),
 				   ksocknal_data.ksnd_reaper_waketime))
 			wake_up(&ksocknal_data.ksnd_reaper_waitq);
@@ -612,7 +612,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
 	conn = (typed) ? typed : fallback;
 
 	if (conn)
-		conn->ksnc_tx_last_post = cfs_time_current();
+		conn->ksnc_tx_last_post = jiffies;
 
 	return conn;
 }
@@ -680,7 +680,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
 		conn->ksnc_tx_deadline =
 			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
 		if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
-			conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
+			conn->ksnc_peer->ksnp_last_alive = jiffies;
 		conn->ksnc_tx_bufnob = 0;
 		mb(); /* order with adding to tx_queue */
 	}
@@ -728,7 +728,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
 struct ksock_route *
 ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
 {
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	struct list_head *tmp;
 	struct ksock_route *route;
 
@@ -1777,7 +1777,7 @@ ksocknal_connect(struct ksock_route *route)
 	int retry_later = 0;
 	int rc = 0;
 
-	deadline = cfs_time_add(cfs_time_current(),
+	deadline = cfs_time_add(jiffies,
 				*ksocknal_tunables.ksnd_timeout * HZ);
 
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -1825,7 +1825,7 @@ ksocknal_connect(struct ksock_route *route)
 
 		write_unlock_bh(&ksocknal_data.ksnd_global_lock);
 
-		if (cfs_time_aftereq(cfs_time_current(), deadline)) {
+		if (cfs_time_aftereq(jiffies, deadline)) {
 			rc = -ETIMEDOUT;
 			lnet_connect_console_error(rc, peer->ksnp_id.nid,
 						   route->ksnr_ipaddr,
@@ -1877,7 +1877,7 @@ ksocknal_connect(struct ksock_route *route)
 			 */
 			route->ksnr_retry_interval =
 				*ksocknal_tunables.ksnd_min_reconnectms * HZ / 1000;
-			route->ksnr_timeout = cfs_time_add(cfs_time_current(),
+			route->ksnr_timeout = cfs_time_add(jiffies,
 							   route->ksnr_retry_interval);
 		}
 
@@ -1903,7 +1903,7 @@ ksocknal_connect(struct ksock_route *route)
 		    (long)*ksocknal_tunables.ksnd_max_reconnectms * HZ / 1000);
 
 	LASSERT(route->ksnr_retry_interval);
-	route->ksnr_timeout = cfs_time_add(cfs_time_current(),
+	route->ksnr_timeout = cfs_time_add(jiffies,
 					   route->ksnr_retry_interval);
 
 	if (!list_empty(&peer->ksnp_tx_queue) &&
@@ -2050,7 +2050,7 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
 	struct ksock_route *route;
 	unsigned long now;
 
-	now = cfs_time_current();
+	now = jiffies;
 
 	/* connd_routes can contain both pending and ordinary routes */
 	list_for_each_entry(route, &ksocknal_data.ksnd_connd_routes,
@@ -2228,7 +2228,7 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
 		}
 
 		if (conn->ksnc_rx_started &&
-		    cfs_time_aftereq(cfs_time_current(),
+		    cfs_time_aftereq(jiffies,
 				     conn->ksnc_rx_deadline)) {
 			/* Timed out incomplete incoming message */
 			ksocknal_conn_addref(conn);
@@ -2244,7 +2244,7 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
 
 		if ((!list_empty(&conn->ksnc_tx_queue) ||
 		     conn->ksnc_sock->sk->sk_wmem_queued) &&
-		    cfs_time_aftereq(cfs_time_current(),
+		    cfs_time_aftereq(jiffies,
 				     conn->ksnc_tx_deadline)) {
 			/*
 			 * Timed out messages queued for sending or
@@ -2272,7 +2272,7 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer)
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
 	list_for_each_entry_safe(tx, tmp, &peer->ksnp_tx_queue, tx_list) {
-		if (!cfs_time_aftereq(cfs_time_current(),
+		if (!cfs_time_aftereq(jiffies,
 				      tx->tx_deadline))
 			break;
 
@@ -2301,12 +2301,12 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
 		return 0;
 
 	if (*ksocknal_tunables.ksnd_keepalive <= 0 ||
-	    time_before(cfs_time_current(),
+	    time_before(jiffies,
 			cfs_time_add(peer->ksnp_last_alive,
 				     *ksocknal_tunables.ksnd_keepalive * HZ)))
 		return 0;
 
-	if (time_before(cfs_time_current(), peer->ksnp_send_keepalive))
+	if (time_before(jiffies, peer->ksnp_send_keepalive))
 		return 0;
 
 	/*
@@ -2400,7 +2400,7 @@ ksocknal_check_peer_timeouts(int idx)
 			tx = list_entry(peer->ksnp_tx_queue.next,
 					struct ksock_tx, tx_list);
 
-			if (cfs_time_aftereq(cfs_time_current(),
+			if (cfs_time_aftereq(jiffies,
 					     tx->tx_deadline)) {
 				ksocknal_peer_addref(peer);
 				read_unlock(&ksocknal_data.ksnd_global_lock);
@@ -2418,7 +2418,7 @@ ksocknal_check_peer_timeouts(int idx)
 		tx_stale = NULL;
 		spin_lock(&peer->ksnp_lock);
 		list_for_each_entry(tx, &peer->ksnp_zc_req_list, tx_zc_list) {
-			if (!cfs_time_aftereq(cfs_time_current(),
+			if (!cfs_time_aftereq(jiffies,
 					      tx->tx_deadline))
 				break;
 			/* ignore the TX if connection is being closed */
@@ -2444,7 +2444,7 @@ ksocknal_check_peer_timeouts(int idx)
 
 		CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n",
 		       n, libcfs_nid2str(peer->ksnp_id.nid), tx_stale,
-		       cfs_duration_sec(cfs_time_current() - deadline),
+		       cfs_duration_sec(jiffies - deadline),
 		       resid, conn->ksnc_sock->sk->sk_wmem_queued);
 
 		ksocknal_close_conn_and_siblings(conn, -ETIMEDOUT);
@@ -2466,7 +2466,7 @@ ksocknal_reaper(void *arg)
 	long timeout;
 	int i;
 	int peer_index = 0;
-	unsigned long deadline = cfs_time_current();
+	unsigned long deadline = jiffies;
 
 	INIT_LIST_HEAD(&enomem_conns);
 	init_waitqueue_entry(&wait, current);
@@ -2532,7 +2532,7 @@ ksocknal_reaper(void *arg)
 
 		/* careful with the jiffy wrap... */
 		while ((timeout = cfs_time_sub(deadline,
-					       cfs_time_current())) <= 0) {
+					       jiffies)) <= 0) {
 			const int n = 4;
 			const int p = 1;
 			int chunk = ksocknal_data.ksnd_peer_hash_size;
@@ -2569,7 +2569,7 @@ ksocknal_reaper(void *arg)
 			timeout = SOCKNAL_ENOMEM_RETRY;
 		}
 		ksocknal_data.ksnd_reaper_waketime =
-			cfs_time_add(cfs_time_current(), timeout);
+			cfs_time_add(jiffies, timeout);
 
 		set_current_state(TASK_INTERRUPTIBLE);
 		add_wait_queue(&ksocknal_data.ksnd_reaper_waitq, &wait);
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 4affca750bc5..2aeae0331ee0 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -431,7 +431,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 	if (cdls) {
 		if (libcfs_console_ratelimit &&
 		    cdls->cdls_next &&		/* not first time ever */
-		    !cfs_time_after(cfs_time_current(), cdls->cdls_next)) {
+		    !cfs_time_after(jiffies, cdls->cdls_next)) {
 			/* skipping a console message */
 			cdls->cdls_count++;
 			if (tcd)
@@ -439,7 +439,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 			return 1;
 		}
 
-		if (cfs_time_after(cfs_time_current(),
+		if (cfs_time_after(jiffies,
 				   cdls->cdls_next + libcfs_console_max_delay +
 				   10 * HZ)) {
 			/* last timeout was a long time ago */
@@ -454,7 +454,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 			cdls->cdls_delay = libcfs_console_max_delay;
 
 		/* ensure cdls_next is never zero after it's been seen */
-		cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1;
+		cdls->cdls_next = (jiffies + cdls->cdls_delay) | 1;
 	}
 
 	if (tcd) {
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index ed43b3f4b114..289ed876bd81 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -501,7 +501,7 @@ lnet_ni_query_locked(struct lnet_ni *ni, struct lnet_peer *lp)
 	ni->ni_lnd->lnd_query(ni, lp->lp_nid, &last_alive);
 	lnet_net_lock(lp->lp_cpt);
 
-	lp->lp_last_query = cfs_time_current();
+	lp->lp_last_query = jiffies;
 
 	if (last_alive) /* NI has updated timestamp */
 		lp->lp_last_alive = last_alive;
@@ -545,7 +545,7 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
 static int
 lnet_peer_alive_locked(struct lnet_peer *lp)
 {
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 
 	if (!lnet_peer_aliveness_enabled(lp))
 		return -ENODEV;
diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
index a63b7941d435..3928e9a74d6f 100644
--- a/drivers/staging/lustre/lnet/lnet/net_fault.c
+++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
@@ -306,7 +306,7 @@ drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
 	/* match this rule, check drop rate now */
 	spin_lock(&rule->dr_lock);
 	if (rule->dr_drop_time) { /* time based drop */
-		unsigned long now = cfs_time_current();
+		unsigned long now = jiffies;
 
 		rule->dr_stat.fs_count++;
 		drop = cfs_time_aftereq(now, rule->dr_drop_time);
@@ -472,7 +472,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
 	/* match this rule, check delay rate now */
 	spin_lock(&rule->dl_lock);
 	if (rule->dl_delay_time) { /* time based delay */
-		unsigned long now = cfs_time_current();
+		unsigned long now = jiffies;
 
 		rule->dl_stat.fs_count++;
 		delay = cfs_time_aftereq(now, rule->dl_delay_time);
@@ -562,7 +562,7 @@ delayed_msg_check(struct lnet_delay_rule *rule, bool all,
 {
 	struct lnet_msg *msg;
 	struct lnet_msg *tmp;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 
 	if (!all && rule->dl_msg_send > now)
 		return;
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index 3d4caa609c83..58294149f7b2 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -315,7 +315,7 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
 	lp->lp_alive_count = 0;
 	lp->lp_timestamp = 0;
 	lp->lp_alive = !lnet_peers_start_down(); /* 1 bit!! */
-	lp->lp_last_alive = cfs_time_current(); /* assumes alive */
+	lp->lp_last_alive = jiffies; /* assumes alive */
 	lp->lp_last_query = 0; /* haven't asked NI yet */
 	lp->lp_ping_timestamp = 0;
 	lp->lp_ping_feats = LNET_PING_FEAT_INVAL;
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index a3c3f4959f46..ac9b392a0afa 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -765,7 +765,7 @@ lnet_router_checker_event(struct lnet_event *event)
 	 * we ping alive routers to try to detect router death before
 	 * apps get burned).
 	 */
-	lnet_notify_locked(lp, 1, !event->status, cfs_time_current());
+	lnet_notify_locked(lp, 1, !event->status, jiffies);
 
 	/*
 	 * The router checker will wake up very shortly and do the
@@ -976,7 +976,7 @@ static void
 lnet_ping_router_locked(struct lnet_peer *rtr)
 {
 	struct lnet_rc_data *rcd = NULL;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	int secs;
 
 	lnet_peer_addref_locked(rtr);
@@ -1730,7 +1730,7 @@ int
 lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
 {
 	struct lnet_peer *lp = NULL;
-	unsigned long now = cfs_time_current();
+	unsigned long now = jiffies;
 	int cpt = lnet_cpt_of_nid(nid);
 
 	LASSERT(!in_interrupt());
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 1a71ffebc889..315d067540c0 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -324,7 +324,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 
 		if (peer) {
 			lnet_nid_t nid = peer->lp_nid;
-			unsigned long now = cfs_time_current();
+			unsigned long now = jiffies;
 			unsigned long deadline = peer->lp_ping_deadline;
 			int nrefs = peer->lp_refcount;
 			int nrtrrefs = peer->lp_rtr_refcount;
@@ -509,7 +509,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
 				aliveness = peer->lp_alive ? "up" : "down";
 
 			if (lnet_peer_aliveness_enabled(peer)) {
-				unsigned long now = cfs_time_current();
+				unsigned long now = jiffies;
 				long delta;
 
 				delta = cfs_time_sub(now, peer->lp_last_alive);
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index 6dcc966b293b..68e06e06857d 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -75,7 +75,7 @@ lstcon_rpc_done(struct srpc_client_rpc *rpc)
 		/* not aborted */
 		LASSERT(!crpc->crp_status);
 
-		crpc->crp_stamp = cfs_time_current();
+		crpc->crp_stamp = jiffies;
 		crpc->crp_status = rpc->crpc_status;
 	}
 
@@ -297,14 +297,14 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
 		if (!crpc->crp_posted || /* not posted */
 		    crpc->crp_stamp) {	 /* rpc done or aborted already */
 			if (!crpc->crp_stamp) {
-				crpc->crp_stamp = cfs_time_current();
+				crpc->crp_stamp = jiffies;
 				crpc->crp_status = -EINTR;
 			}
 			spin_unlock(&rpc->crpc_lock);
 			continue;
 		}
 
-		crpc->crp_stamp = cfs_time_current();
+		crpc->crp_stamp = jiffies;
 		crpc->crp_status = error;
 
 		spin_unlock(&rpc->crpc_lock);
diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
index 1acd5cb324b1..1889f1e86473 100644
--- a/drivers/staging/lustre/lnet/selftest/console.c
+++ b/drivers/staging/lustre/lnet/selftest/console.c
@@ -98,7 +98,7 @@ lstcon_node_find(struct lnet_process_id id, struct lstcon_node **ndpp,
 
 	ndl->ndl_node->nd_ref = 1;
 	ndl->ndl_node->nd_id = id;
-	ndl->ndl_node->nd_stamp = cfs_time_current();
+	ndl->ndl_node->nd_stamp = jiffies;
 	ndl->ndl_node->nd_state = LST_NODE_UNKNOWN;
 	ndl->ndl_node->nd_timeout = 0;
 	memset(&ndl->ndl_node->nd_ping, 0, sizeof(struct lstcon_rpc));
@@ -1701,7 +1701,7 @@ lstcon_new_session_id(struct lst_sid *sid)
 
 	LNetGetId(1, &id);
 	sid->ses_nid = id.nid;
-	sid->ses_stamp = cfs_time_current();
+	sid->ses_stamp = jiffies;
 }
 
 int
diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
index 0ca1e3a780ca..045eecd23e0a 100644
--- a/drivers/staging/lustre/lnet/selftest/framework.c
+++ b/drivers/staging/lustre/lnet/selftest/framework.c
@@ -272,7 +272,7 @@ sfw_init_session(struct sfw_session *sn, struct lst_sid sid,
 	sn->sn_id = sid;
 	sn->sn_features = features;
 	sn->sn_timeout = session_timeout;
-	sn->sn_started = cfs_time_current();
+	sn->sn_started = jiffies;
 
 	timer->stt_data = sn;
 	timer->stt_func = sfw_session_expired;
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index d35ae0cda8d2..f4824d8ec741 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -2255,7 +2255,7 @@ static inline int ptlrpc_send_limit_expired(struct ptlrpc_request *req)
 	if (req->rq_delay_limit != 0 &&
 	    time_before(cfs_time_add(req->rq_queued_time,
 				     req->rq_delay_limit * HZ),
-			cfs_time_current())) {
+			jiffies)) {
 		return 1;
 	}
 	return 0;
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index f24dd74ffa09..7cfc3c8d100c 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -913,7 +913,7 @@ static inline int obd_destroy_export(struct obd_export *exp)
 /*
  * @max_age is the oldest time in jiffies that we accept using a cached data.
  * If the cache is older than @max_age we will get a new value from the
- * target.  Use a value of "cfs_time_current() + HZ" to guarantee freshness.
+ * target.  Use a value of "jiffies + HZ" to guarantee freshness.
  */
 static inline int obd_statfs_async(struct obd_export *exp,
 				   struct obd_info *oinfo,
@@ -975,7 +975,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp,
 /*
  * @max_age is the oldest time in jiffies that we accept using a cached data.
  * If the cache is older than @max_age we will get a new value from the
- * target.  Use a value of "cfs_time_current() + HZ" to guarantee freshness.
+ * target.  Use a value of "jiffies + HZ" to guarantee freshness.
  */
 static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
 			     struct obd_statfs *osfs, __u64 max_age,
@@ -997,7 +997,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
 		if (rc == 0) {
 			spin_lock(&obd->obd_osfs_lock);
 			memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
-			obd->obd_osfs_age = cfs_time_current_64();
+			obd->obd_osfs_age = get_jiffies_64();
 			spin_unlock(&obd->obd_osfs_lock);
 		}
 	} else {
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 614caa4a9b0e..22c49cc593e3 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -243,7 +243,7 @@ static void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock)
 {
 	struct ldlm_namespace *ns = ldlm_lock_to_ns(lock);
 
-	lock->l_last_used = cfs_time_current();
+	lock->l_last_used = jiffies;
 	LASSERT(list_empty(&lock->l_lru));
 	LASSERT(lock->l_resource->lr_type != LDLM_FLOCK);
 	list_add_tail(&lock->l_lru, &ns->ns_unused_list);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index c772c68e5a49..ab4dd15c8dd4 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -325,7 +325,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
 	lock_res_and_lock(lock);
 	if (lock->l_granted_mode == LCK_PW &&
 	    !lock->l_readers && !lock->l_writers &&
-	    cfs_time_after(cfs_time_current(),
+	    cfs_time_after(jiffies,
 			   cfs_time_add(lock->l_last_used,
 					10 * HZ))) {
 		unlock_res_and_lock(lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 8e79f5e073ff..0e1b21c1f06d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -116,7 +116,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
 			   (s64)lock->l_last_activity,
 			   (s64)(ktime_get_real_seconds() -
 				 lock->l_last_activity));
-		if (cfs_time_after(cfs_time_current(), next_dump)) {
+		if (cfs_time_after(jiffies, next_dump)) {
 			last_dump = next_dump;
 			next_dump = cfs_time_shift(300);
 			ldlm_namespace_dump(D_DLMTRACE,
@@ -1161,7 +1161,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 						    int unused, int added,
 						    int count)
 {
-	unsigned long cur = cfs_time_current();
+	unsigned long cur = jiffies;
 	struct ldlm_pool *pl = &ns->ns_pool;
 	__u64 slv, lvf, lv;
 	unsigned long la;
@@ -1176,7 +1176,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 	 * Despite of the LV, It doesn't make sense to keep the lock which
 	 * is unused for ns_max_age time.
 	 */
-	if (cfs_time_after(cfs_time_current(),
+	if (cfs_time_after(jiffies,
 			   cfs_time_add(lock->l_last_used, ns->ns_max_age)))
 		return LDLM_POLICY_CANCEL_LOCK;
 
@@ -1233,7 +1233,7 @@ static enum ldlm_policy_res ldlm_cancel_aged_policy(struct ldlm_namespace *ns,
 						    int count)
 {
 	if ((added >= count) &&
-	    time_before(cfs_time_current(),
+	    time_before(jiffies,
 			cfs_time_add(lock->l_last_used, ns->ns_max_age)))
 		return LDLM_POLICY_KEEP_LOCK;
 
@@ -1380,7 +1380,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
 				continue;
 
 			last_use = lock->l_last_used;
-			if (last_use == cfs_time_current())
+			if (last_use == jiffies)
 				continue;
 
 			/* Somebody is already doing CANCEL. No need for this
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 8841a1bb2c0a..ccd0c082e39b 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1316,7 +1316,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
 	CDEBUG(level, "--- Namespace: %s (rc: %d, side: client)\n",
 	       ldlm_ns_name(ns), atomic_read(&ns->ns_bref));
 
-	if (time_before(cfs_time_current(), ns->ns_next_dump))
+	if (time_before(jiffies, ns->ns_next_dump))
 		return;
 
 	cfs_hash_for_each_nolock(ns->ns_rs_hash,
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index d46bcf71b273..6504850e3689 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -1110,7 +1110,7 @@ static inline int ll_glimpse_size(struct inode *inode)
 
 	down_read(&lli->lli_glimpse_sem);
 	rc = cl_glimpse_size(inode);
-	lli->lli_glimpse_time = cfs_time_current();
+	lli->lli_glimpse_time = jiffies;
 	up_read(&lli->lli_glimpse_sem);
 	return rc;
 }
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index 155ce3cf6f60..6f996acf6aa8 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -535,7 +535,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
 
 	cl_agl(inode);
 	lli->lli_agl_index = 0;
-	lli->lli_glimpse_time = cfs_time_current();
+	lli->lli_glimpse_time = jiffies;
 	up_write(&lli->lli_glimpse_sem);
 
 	CDEBUG(D_READA, "Handled (init) async glimpse: inode= "
diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
index 051450d67524..41fc023cc381 100644
--- a/drivers/staging/lustre/lustre/lov/lov_request.c
+++ b/drivers/staging/lustre/lustre/lov/lov_request.c
@@ -160,7 +160,7 @@ static int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,
 
 		spin_lock(&obd->obd_osfs_lock);
 		memcpy(&obd->obd_osfs, osfs, sizeof(*osfs));
-		obd->obd_osfs_age = cfs_time_current_64();
+		obd->obd_osfs_age = get_jiffies_64();
 		spin_unlock(&obd->obd_osfs_lock);
 		return 0;
 	}
@@ -277,7 +277,7 @@ static int cb_statfs_update(void *cookie, int rc)
 	spin_lock(&tgtobd->obd_osfs_lock);
 	memcpy(&tgtobd->obd_osfs, lov_sfs, sizeof(*lov_sfs));
 	if ((oinfo->oi_flags & OBD_STATFS_FROM_CACHE) == 0)
-		tgtobd->obd_osfs_age = cfs_time_current_64();
+		tgtobd->obd_osfs_age = get_jiffies_64();
 	spin_unlock(&tgtobd->obd_osfs_lock);
 
 out_update:
diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
index 459503727ce3..ba4a4bf3b0f1 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -1290,7 +1290,7 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
 
 	result = cl_page_make_ready(env, page, CRT_WRITE);
 	if (result == 0)
-		opg->ops_submit_time = cfs_time_current();
+		opg->ops_submit_time = jiffies;
 	return result;
 }
 
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index 9582d5a642e2..c5dc894a4c1b 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -300,7 +300,7 @@ static int osc_object_fiemap(const struct lu_env *env, struct cl_object *obj,
 
 void osc_object_set_contended(struct osc_object *obj)
 {
-	obj->oo_contention_time = cfs_time_current();
+	obj->oo_contention_time = jiffies;
 	/* mb(); */
 	obj->oo_contended = 1;
 }
@@ -314,7 +314,7 @@ int osc_object_is_contended(struct osc_object *obj)
 {
 	struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
 	int osc_contention_time = dev->od_contention_time;
-	unsigned long cur_time = cfs_time_current();
+	unsigned long cur_time = jiffies;
 	unsigned long retry_time;
 
 	if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index 01a930dbbf64..20c553ef3a5e 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -125,7 +125,7 @@ static inline unsigned long osc_submit_duration(struct osc_page *opg)
 	if (opg->ops_submit_time == 0)
 		return 0;
 
-	return (cfs_time_current() - opg->ops_submit_time);
+	return (jiffies - opg->ops_submit_time);
 }
 
 static int osc_page_print(const struct lu_env *env,
@@ -312,7 +312,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
 		oap->oap_cmd |= OBD_BRW_NOQUOTA;
 	}
 
-	opg->ops_submit_time = cfs_time_current();
+	opg->ops_submit_time = jiffies;
 	osc_page_transfer_get(opg, "transfer\0imm");
 	osc_page_transfer_add(env, opg, crt);
 }
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 1c2bbbf5d864..9966fc7af789 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -741,7 +741,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
 
 static int osc_should_shrink_grant(struct client_obd *client)
 {
-	unsigned long time = cfs_time_current();
+	unsigned long time = jiffies;
 	unsigned long next_shrink = client->cl_next_shrink_grant;
 
 	if ((client->cl_import->imp_connect_data.ocd_connect_flags &
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index ca096fadb9c0..eeb281266413 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -1050,7 +1050,7 @@ void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
 	list_add_tail(&req->rq_set_chain, &set->set_requests);
 	req->rq_set = set;
 	atomic_inc(&set->set_remaining);
-	req->rq_queued_time = cfs_time_current();
+	req->rq_queued_time = jiffies;
 
 	if (req->rq_reqmsg)
 		lustre_msg_set_jobid(req->rq_reqmsg, NULL);
@@ -1081,7 +1081,7 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
 	spin_lock(&set->set_new_req_lock);
 	/* The set takes over the caller's request reference.  */
 	req->rq_set = set;
-	req->rq_queued_time = cfs_time_current();
+	req->rq_queued_time = jiffies;
 	list_add_tail(&req->rq_set_chain, &set->set_new_requests);
 	count = atomic_inc_return(&set->set_new_count);
 	spin_unlock(&set->set_new_req_lock);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index a2c4fc3488b1..4a9d1f189d01 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -508,7 +508,7 @@ static int import_select_connection(struct obd_import *imp)
 		       imp->imp_obd->obd_name, at_get(at));
 	}
 
-	imp_conn->oic_last_attempt = cfs_time_current_64();
+	imp_conn->oic_last_attempt = get_jiffies_64();
 
 	/* switch connection, don't mind if it's same as the current one */
 	ptlrpc_connection_put(imp->imp_connection);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 0775b7a048bb..57c7db47e249 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -142,7 +142,7 @@ static long pinger_check_timeout(unsigned long time)
 	mutex_unlock(&pinger_mutex);
 
 	return cfs_time_sub(cfs_time_add(time, timeout * HZ),
-					 cfs_time_current());
+					 jiffies);
 }
 
 static bool ir_up;
@@ -223,7 +223,7 @@ static DECLARE_DELAYED_WORK(ping_work, ptlrpc_pinger_main);
 
 static void ptlrpc_pinger_main(struct work_struct *ws)
 {
-	unsigned long this_ping = cfs_time_current();
+	unsigned long this_ping = jiffies;
 	long time_to_next_wake;
 	struct timeout_item *item;
 	struct obd_import *imp;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index f37364e00dfe..fc29efbd9914 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -336,7 +336,7 @@ static void ptlrpc_at_timer(struct timer_list *t)
 	svcpt = from_timer(svcpt, t, scp_at_timer);
 
 	svcpt->scp_at_check = 1;
-	svcpt->scp_at_checktime = cfs_time_current();
+	svcpt->scp_at_checktime = jiffies;
 	wake_up(&svcpt->scp_waitq);
 }
 
@@ -1153,7 +1153,7 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
 		spin_unlock(&svcpt->scp_at_lock);
 		return;
 	}
-	delay = cfs_time_sub(cfs_time_current(), svcpt->scp_at_checktime);
+	delay = cfs_time_sub(jiffies, svcpt->scp_at_checktime);
 	svcpt->scp_at_check = 0;
 
 	if (array->paa_count == 0) {

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

This function simply multiplies by HZ and adds jiffies.
This is simple enough to be opencoded, and doing so
makes the code easier to read.

Same for cfs_time_shift_64()

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/include/linux/libcfs/libcfs_time.h      |    5 ----
 .../lustre/include/linux/libcfs/linux/linux-time.h |    5 ----
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   12 +++++----
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    4 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 ++-
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   12 +++++----
 drivers/staging/lustre/lnet/lnet/net_fault.c       |   26 ++++++++++----------
 drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c    |    4 ++-
 drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +++++----
 drivers/staging/lustre/lustre/llite/statahead.c    |    2 +-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    2 +-
 drivers/staging/lustre/lustre/lov/lov_obd.c        |    2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 +-
 .../lustre/lustre/obdclass/lprocfs_status.c        |   12 +++++----
 .../staging/lustre/lustre/obdclass/obd_config.c    |    2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +-
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    6 ++---
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    2 +-
 21 files changed, 56 insertions(+), 66 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 7b41a129f041..0ebbde4ec8e8 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -50,11 +50,6 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
 	return time_before_eq(t2, t1);
 }
 
-static inline unsigned long cfs_time_shift(int seconds)
-{
-	return jiffies + seconds * HZ;
-}
-
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index b3a80531bd71..ff3aae2f1231 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -65,11 +65,6 @@ static inline long cfs_duration_sec(long d)
 	return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-static inline u64 cfs_time_shift_64(int seconds)
-{
-	return get_jiffies_64() + (u64)seconds * HZ;
-}
-
 static inline int cfs_time_before_64(u64 t1, u64 t2)
 {
 	return (__s64)t2 - (__s64)t1 > 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 7df07f39b849..276bf486f64b 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1446,7 +1446,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps,
 	if (rc)
 		goto out_fpo;
 
-	fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+	fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
 	fpo->fpo_owner = fps;
 	*pp_fpo = fpo;
 
@@ -1619,7 +1619,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
 	spin_lock(&fps->fps_lock);
 	version = fps->fps_version;
 	list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
-		fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+		fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
 		fpo->fpo_map_count++;
 
 		if (fpo->fpo_is_fmr) {
@@ -1743,7 +1743,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
 		fps->fps_version++;
 		list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
 	} else {
-		fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
+		fps->fps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
 	}
 	spin_unlock(&fps->fps_lock);
 
@@ -1764,7 +1764,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, struct kib_pool *pool, int
 
 	memset(pool, 0, sizeof(*pool));
 	INIT_LIST_HEAD(&pool->po_free_list);
-	pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+	pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
 	pool->po_owner    = ps;
 	pool->po_size     = size;
 }
@@ -1899,7 +1899,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
 			continue;
 
 		pool->po_allocated++;
-		pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+		pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
 		node = pool->po_free_list.next;
 		list_del(node);
 
@@ -1947,7 +1947,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
 	if (!rc) {
 		list_add_tail(&pool->po_list, &ps->ps_pool_list);
 	} else {
-		ps->ps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
+		ps->ps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
 		CERROR("Can't allocate new %s pool because out of memory\n",
 		       ps->ps_name);
 	}
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index c1c3277f4c1f..f9761d8f2e3e 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3700,13 +3700,13 @@ kiblnd_failover_thread(void *arg)
 			LASSERT(dev->ibd_failover);
 			dev->ibd_failover = 0;
 			if (rc >= 0) { /* Device is OK or failover succeed */
-				dev->ibd_next_failover = cfs_time_shift(3);
+				dev->ibd_next_failover = jiffies + 3 * HZ;
 				continue;
 			}
 
 			/* failed to failover, retry later */
 			dev->ibd_next_failover =
-				cfs_time_shift(min(dev->ibd_failed_failover, 10));
+				jiffies + min(dev->ibd_failed_failover, 10) * HZ;
 			if (kiblnd_dev_can_failover(dev)) {
 				list_add_tail(&dev->ibd_fail_list,
 					      &kiblnd_data.kib_failed_devs);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 4546618c1c12..16c1ab0b0bd9 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1287,7 +1287,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
 	conn->ksnc_tx_last_post = jiffies;
 	/* Set the deadline for the outgoing HELLO to drain */
 	conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
-	conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+	conn->ksnc_tx_deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 	mb();   /* order with adding to peer's conn list */
 
 	list_add(&conn->ksnc_list, &peer->ksnp_conns);
@@ -1852,7 +1852,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
 			if (bufnob < conn->ksnc_tx_bufnob) {
 				/* something got ACKed */
 				conn->ksnc_tx_deadline =
-					cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+					jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 				peer->ksnp_last_alive = now;
 				conn->ksnc_tx_bufnob = bufnob;
 			}
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 5b34c7c030ad..1ace54c9b133 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -221,7 +221,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 			 * something got ACKed
 			 */
 			conn->ksnc_tx_deadline =
-				cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+				jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 			conn->ksnc_peer->ksnp_last_alive = jiffies;
 			conn->ksnc_tx_bufnob = bufnob;
 			mb();
@@ -269,7 +269,7 @@ ksocknal_recv_iter(struct ksock_conn *conn)
 
 	conn->ksnc_peer->ksnp_last_alive = jiffies;
 	conn->ksnc_rx_deadline =
-		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 	mb();		       /* order with setting rx_started */
 	conn->ksnc_rx_started = 1;
 
@@ -405,7 +405,7 @@ ksocknal_check_zc_req(struct ksock_tx *tx)
 
 	/* ZC_REQ is going to be pinned to the peer */
 	tx->tx_deadline =
-		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 
 	LASSERT(!tx->tx_msg.ksm_zc_cookies[0]);
 
@@ -677,7 +677,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
 	if (list_empty(&conn->ksnc_tx_queue) && !bufnob) {
 		/* First packet starts the timeout */
 		conn->ksnc_tx_deadline =
-			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 		if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
 			conn->ksnc_peer->ksnp_last_alive = jiffies;
 		conn->ksnc_tx_bufnob = 0;
@@ -858,7 +858,7 @@ ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
 	    ksocknal_find_connecting_route_locked(peer)) {
 		/* the message is going to be pinned to the peer */
 		tx->tx_deadline =
-			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 
 		/* Queue the message until a connection is established */
 		list_add_tail(&tx->tx_list, &peer->ksnp_tx_queue);
@@ -2308,7 +2308,7 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
 	 * retry 10 secs later, so we wouldn't put pressure
 	 * on this peer if we failed to send keepalive this time
 	 */
-	peer->ksnp_send_keepalive = cfs_time_shift(10);
+	peer->ksnp_send_keepalive = jiffies + 10 * HZ;
 
 	conn = ksocknal_find_conn_locked(peer, NULL, 1);
 	if (conn) {
diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
index 3928e9a74d6f..05d7b754815a 100644
--- a/drivers/staging/lustre/lnet/lnet/net_fault.c
+++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
@@ -169,9 +169,9 @@ lnet_drop_rule_add(struct lnet_fault_attr *attr)
 
 	rule->dr_attr = *attr;
 	if (attr->u.drop.da_interval) {
-		rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
-		rule->dr_drop_time = cfs_time_shift(
-			prandom_u32_max(attr->u.drop.da_interval));
+		rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
+		rule->dr_drop_time = jiffies +
+			prandom_u32_max(attr->u.drop.da_interval) * HZ;
 	} else {
 		rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
 	}
@@ -279,9 +279,9 @@ lnet_drop_rule_reset(void)
 		if (attr->u.drop.da_rate) {
 			rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
 		} else {
-			rule->dr_drop_time = cfs_time_shift(
-				prandom_u32_max(attr->u.drop.da_interval));
-			rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
+			rule->dr_drop_time = jiffies +
+				prandom_u32_max(attr->u.drop.da_interval) * HZ;
+			rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
 		}
 		spin_unlock(&rule->dr_lock);
 	}
@@ -513,7 +513,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
 
 	list_add_tail(&msg->msg_list, &rule->dl_msg_list);
 	msg->msg_delay_send = round_timeout(
-			cfs_time_shift(attr->u.delay.la_latency));
+			jiffies + attr->u.delay.la_latency * HZ);
 	if (rule->dl_msg_send == -1) {
 		rule->dl_msg_send = msg->msg_delay_send;
 		mod_timer(&rule->dl_timer, rule->dl_msg_send);
@@ -767,9 +767,9 @@ lnet_delay_rule_add(struct lnet_fault_attr *attr)
 
 	rule->dl_attr = *attr;
 	if (attr->u.delay.la_interval) {
-		rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
-		rule->dl_delay_time = cfs_time_shift(
-			prandom_u32_max(attr->u.delay.la_interval));
+		rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
+		rule->dl_delay_time = jiffies + 
+			prandom_u32_max(attr->u.delay.la_interval) * HZ;
 	} else {
 		rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
 	}
@@ -920,9 +920,9 @@ lnet_delay_rule_reset(void)
 			rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
 		} else {
 			rule->dl_delay_time =
-				cfs_time_shift(prandom_u32_max(
-						       attr->u.delay.la_interval));
-			rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
+				jiffies + prandom_u32_max(
+					attr->u.delay.la_interval) * HZ;
+			rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
 		}
 		spin_unlock(&rule->dl_lock);
 	}
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index 4595a7ad4336..c72d4f4454ec 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -1026,7 +1026,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
 
 		if (!rtr->lp_ping_deadline) {
 			rtr->lp_ping_deadline =
-				cfs_time_shift(router_ping_timeout);
+				jiffies + router_ping_timeout * HZ;
 		}
 
 		lnet_net_unlock(rtr->lp_cpt);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 6eb42f16040d..647e85b16c02 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -118,7 +118,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
 				 lock->l_last_activity));
 		if (cfs_time_after(jiffies, next_dump)) {
 			last_dump = next_dump;
-			next_dump = cfs_time_shift(300);
+			next_dump = jiffies + 300 * HZ;
 			ldlm_namespace_dump(D_DLMTRACE,
 					    ldlm_lock_to_ns(lock));
 			if (last_dump == 0)
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index ccd0c082e39b..6c615b6e9bdc 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -1323,7 +1323,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
 				 ldlm_res_hash_dump,
 				 (void *)(unsigned long)level, 0);
 	spin_lock(&ns->ns_lock);
-	ns->ns_next_dump = cfs_time_shift(10);
+	ns->ns_next_dump = jiffies + 10 * HZ;
 	spin_unlock(&ns->ns_lock);
 }
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index e7500c53fafc..60dbe888e336 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -257,7 +257,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 	 * available
 	 */
 	err = obd_statfs(NULL, sbi->ll_md_exp, osfs,
-			 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			 get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			 OBD_STATFS_FOR_MDT0);
 	if (err)
 		goto out_md_fid;
@@ -1675,7 +1675,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
 
 	/* Some amount of caching on the client is allowed */
 	rc = ll_statfs_internal(sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				0);
 	if (rc)
 		return rc;
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 644bea2f9d37..164fe4d6b6b8 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -53,7 +53,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%u\n", osfs.os_bsize);
@@ -71,7 +71,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -96,7 +96,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -121,7 +121,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -146,7 +146,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%llu\n", osfs.os_files);
@@ -164,7 +164,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
 	int rc;
 
 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%llu\n", osfs.os_ffree);
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index 6f996acf6aa8..b4a6ee6c83f3 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -523,7 +523,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
 	 *    affect the performance.
 	 */
 	if (lli->lli_glimpse_time != 0 &&
-	    time_before(cfs_time_shift(-1), lli->lli_glimpse_time)) {
+	    time_before(jiffies - 1 * HZ, lli->lli_glimpse_time)) {
 		up_write(&lli->lli_glimpse_sem);
 		lli->lli_agl_index = 0;
 		iput(inode);
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index e8a9b9902c37..7be931039e3c 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -876,7 +876,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
 			return -EFAULT;
 
 		rc = obd_statfs(NULL, tgt->ltd_exp, &stat_buf,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				0);
 		if (rc)
 			return rc;
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index ec70c12e5b40..355e87ecc62d 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -1063,7 +1063,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
 		/* got statfs data */
 		rc = obd_statfs(NULL, lov->lov_tgts[index]->ltd_exp, &stat_buf,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				flags);
 		if (rc)
 			return rc;
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 3b1c8e5a3053..266fa90cb03d 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -2104,7 +2104,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 		}
 
 		rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf,
-				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 				0);
 		if (rc != 0)
 			goto out;
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 2ed350527398..eb6396add78d 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -407,7 +407,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%u\n", osfs.os_bsize);
@@ -423,7 +423,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -446,7 +446,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -469,7 +469,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc) {
 		__u32 blk_size = osfs.os_bsize >> 10;
@@ -492,7 +492,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%llu\n", osfs.os_files);
@@ -508,7 +508,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
 					      obd_kobj);
 	struct obd_statfs  osfs;
 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
-			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
+			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
 			    OBD_STATFS_NODELAY);
 	if (!rc)
 		return sprintf(buf, "%llu\n", osfs.os_ffree);
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 277576b586db..eab03766236f 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -269,7 +269,7 @@ static int class_attach(struct lustre_cfg *lcfg)
 	/* obd->obd_osfs_age must be set to a value in the distant
 	 * past to guarantee a fresh statfs is fetched on mount.
 	 */
-	obd->obd_osfs_age = cfs_time_shift_64(-1000);
+	obd->obd_osfs_age = get_jiffies_64() - 1000 * HZ;
 
 	/* XXX belongs in setup not attach  */
 	init_rwsem(&obd->obd_observer_link_sem);
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 9966fc7af789..04d801f11ace 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -617,7 +617,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
 void osc_update_next_shrink(struct client_obd *cli)
 {
 	cli->cl_next_shrink_grant =
-		cfs_time_shift(cli->cl_grant_shrink_interval);
+		jiffies + cli->cl_grant_shrink_interval * HZ;
 	CDEBUG(D_CACHE, "next time %ld to shrink grant\n",
 	       cli->cl_next_shrink_grant);
 }
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index e836591c5936..7057b4447035 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -108,7 +108,7 @@ static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
 				  at_get(&imp->imp_at.iat_net_latency));
 		time = min(time, dtime);
 	}
-	imp->imp_next_ping = cfs_time_shift(time);
+	imp->imp_next_ping = jiffies + time * HZ;
 }
 
 static inline int imp_is_deactive(struct obd_import *imp)
@@ -120,9 +120,9 @@ static inline int imp_is_deactive(struct obd_import *imp)
 static inline int ptlrpc_next_reconnect(struct obd_import *imp)
 {
 	if (imp->imp_server_timeout)
-		return cfs_time_shift(obd_timeout / 2);
+		return jiffies + obd_timeout / 2 * HZ;
 	else
-		return cfs_time_shift(obd_timeout);
+		return jiffies + obd_timeout * HZ;
 }
 
 static long pinger_check_timeout(unsigned long time)
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index e71046db28e5..4265e8d00ca5 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -922,7 +922,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
 	if (next <= 0) {
 		ptlrpc_at_timer(&svcpt->scp_at_timer);
 	} else {
-		mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
+		mod_timer(&svcpt->scp_at_timer, jiffies + next * HZ);
 		CDEBUG(D_INFO, "armed %s at %+ds\n",
 		       svcpt->scp_service->srv_name, next);
 	}

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 07/17] staging: lustre: ldlm: free resource when ldlm_lock_create() fails.
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

ldlm_lock_create() gets a resource, but don't put it on
all failure paths. It should.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index b8fd778d9832..614caa4a9b0e 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1551,8 +1551,10 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
 		return ERR_CAST(res);
 
 	lock = ldlm_lock_new(res);
-	if (!lock)
+	if (!lock) {
+		ldlm_resource_putref(res);
 		return ERR_PTR(-ENOMEM);
+	}
 
 	lock->l_req_mode = mode;
 	lock->l_ast_data = data;
@@ -1595,6 +1597,8 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
 	return ERR_PTR(rc);
 }
 
+
+
 /**
  * Enqueue (request) a lock.
  * On the client this is called from ldlm_cli_enqueue_fini

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 10/17] staging: lustre: libcfs: discard cfs_time_add/sub
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

cfs_time_add adds its arguments.
cfs_time_sub subtracts finds the difference.
Discard these and use '+' and '-' directly.

This change highlighted a type error.  The structure field
cr_queued_time was used to store jiffies, but was declared
as time_t (meant for seconds).  So the time is changed to
"unsigned long".

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/include/linux/libcfs/libcfs_time.h      |   12 +---------
 .../lustre/include/linux/libcfs/linux/linux-time.h |    8 +------
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    2 +-
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   23 +++++++-------------
 drivers/staging/lustre/lnet/lnet/lib-move.c        |    6 ++---
 drivers/staging/lustre/lnet/lnet/router.c          |    5 ++--
 drivers/staging/lustre/lnet/lnet/router_proc.c     |    7 +++---
 drivers/staging/lustre/lnet/selftest/conrpc.c      |    4 ++-
 drivers/staging/lustre/lnet/selftest/timer.c       |    2 +-
 drivers/staging/lustre/lustre/include/lustre_net.h |    5 ++--
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    3 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    8 +++----
 drivers/staging/lustre/lustre/osc/osc_object.c     |    3 +--
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    9 +++-----
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    2 +-
 15 files changed, 32 insertions(+), 67 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index df7a3f13f3b3..7b41a129f041 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -40,16 +40,6 @@
  * generic time manipulation functions.
  */
 
-static inline unsigned long cfs_time_add(unsigned long t, long d)
-{
-	return (unsigned long)(t + d);
-}
-
-static inline unsigned long cfs_time_sub(unsigned long t1, unsigned long t2)
-{
-	return (unsigned long)(t1 - t2);
-}
-
 static inline int cfs_time_after(unsigned long t1, unsigned long t2)
 {
 	return time_before(t2, t1);
@@ -62,7 +52,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
 
 static inline unsigned long cfs_time_shift(int seconds)
 {
-	return cfs_time_add(jiffies, seconds * HZ);
+	return jiffies + seconds * HZ;
 }
 
 /*
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ba115e8c820f..b3a80531bd71 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -65,15 +65,9 @@ static inline long cfs_duration_sec(long d)
 	return d / msecs_to_jiffies(MSEC_PER_SEC);
 }
 
-static inline u64 cfs_time_add_64(u64 t, u64 d)
-{
-	return t + d;
-}
-
 static inline u64 cfs_time_shift_64(int seconds)
 {
-	return cfs_time_add_64(get_jiffies_64(),
-			       seconds * HZ);
+	return get_jiffies_64() + (u64)seconds * HZ;
 }
 
 static inline int cfs_time_before_64(u64 t1, u64 t2)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 0efde0009a15..4546618c1c12 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
 		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
 		       &conn->ksnc_ipaddr, conn->ksnc_port,
 		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
-		       cfs_duration_sec(cfs_time_sub(jiffies, last_rcv)));
+		       cfs_duration_sec(jiffies - last_rcv));
 		lnet_finalize(conn->ksnc_peer->ksnp_ni,
 			      conn->ksnc_cookie, -EIO);
 		break;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index f97da4540b51..5b34c7c030ad 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -481,8 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 		LASSERT(conn->ksnc_tx_scheduled);
 		list_add_tail(&conn->ksnc_tx_list,
 			      &ksocknal_data.ksnd_enomem_conns);
-		if (!cfs_time_aftereq(cfs_time_add(jiffies,
-						   SOCKNAL_ENOMEM_RETRY),
+		if (!cfs_time_aftereq(jiffies + SOCKNAL_ENOMEM_RETRY,
 				   ksocknal_data.ksnd_reaper_waketime))
 			wake_up(&ksocknal_data.ksnd_reaper_waitq);
 
@@ -1777,8 +1776,7 @@ ksocknal_connect(struct ksock_route *route)
 	int retry_later = 0;
 	int rc = 0;
 
-	deadline = cfs_time_add(jiffies,
-				*ksocknal_tunables.ksnd_timeout * HZ);
+	deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
 
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
@@ -1877,8 +1875,7 @@ ksocknal_connect(struct ksock_route *route)
 			 */
 			route->ksnr_retry_interval =
 				*ksocknal_tunables.ksnd_min_reconnectms * HZ / 1000;
-			route->ksnr_timeout = cfs_time_add(jiffies,
-							   route->ksnr_retry_interval);
+			route->ksnr_timeout = jiffies + route->ksnr_retry_interval;
 		}
 
 		ksocknal_launch_connection_locked(route);
@@ -1903,8 +1900,7 @@ ksocknal_connect(struct ksock_route *route)
 		    (long)*ksocknal_tunables.ksnd_max_reconnectms * HZ / 1000);
 
 	LASSERT(route->ksnr_retry_interval);
-	route->ksnr_timeout = cfs_time_add(jiffies,
-					   route->ksnr_retry_interval);
+	route->ksnr_timeout = jiffies + route->ksnr_retry_interval;
 
 	if (!list_empty(&peer->ksnp_tx_queue) &&
 	    !peer->ksnp_accepting &&
@@ -2302,8 +2298,7 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
 
 	if (*ksocknal_tunables.ksnd_keepalive <= 0 ||
 	    time_before(jiffies,
-			cfs_time_add(peer->ksnp_last_alive,
-				     *ksocknal_tunables.ksnd_keepalive * HZ)))
+			peer->ksnp_last_alive + *ksocknal_tunables.ksnd_keepalive * HZ))
 		return 0;
 
 	if (time_before(jiffies, peer->ksnp_send_keepalive))
@@ -2531,8 +2526,7 @@ ksocknal_reaper(void *arg)
 		}
 
 		/* careful with the jiffy wrap... */
-		while ((timeout = cfs_time_sub(deadline,
-					       jiffies)) <= 0) {
+		while ((timeout = deadline - jiffies) <= 0) {
 			const int n = 4;
 			const int p = 1;
 			int chunk = ksocknal_data.ksnd_peer_hash_size;
@@ -2557,7 +2551,7 @@ ksocknal_reaper(void *arg)
 					     ksocknal_data.ksnd_peer_hash_size;
 			}
 
-			deadline = cfs_time_add(deadline, p * HZ);
+			deadline = deadline + p * HZ;
 		}
 
 		if (nenomem_conns) {
@@ -2568,8 +2562,7 @@ ksocknal_reaper(void *arg)
 			 */
 			timeout = SOCKNAL_ENOMEM_RETRY;
 		}
-		ksocknal_data.ksnd_reaper_waketime =
-			cfs_time_add(jiffies, timeout);
+		ksocknal_data.ksnd_reaper_waketime = jiffies + timeout;
 
 		set_current_state(TASK_INTERRUPTIBLE);
 		add_wait_queue(&ksocknal_data.ksnd_reaper_waitq, &wait);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index 289ed876bd81..5574d2148c9d 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -523,8 +523,7 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
 	    cfs_time_aftereq(lp->lp_timestamp, lp->lp_last_alive))
 		return 0;
 
-	deadline = cfs_time_add(lp->lp_last_alive,
-				lp->lp_ni->ni_peertimeout * HZ);
+	deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout * HZ;
 	alive = cfs_time_after(deadline, now);
 
 	/* Update obsolete lp_alive except for routers assumed to be dead
@@ -561,8 +560,7 @@ lnet_peer_alive_locked(struct lnet_peer *lp)
 		static const int lnet_queryinterval = 1;
 
 		unsigned long next_query =
-			   cfs_time_add(lp->lp_last_query,
-					lnet_queryinterval * HZ);
+			   lp->lp_last_query + lnet_queryinterval * HZ;
 
 		if (time_before(now, next_query)) {
 			if (lp->lp_alive)
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index ac9b392a0afa..4595a7ad4336 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -1010,8 +1010,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
 	       rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
 
 	if (secs && !rtr->lp_ping_notsent &&
-	    cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp,
-					     secs * HZ))) {
+	    cfs_time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
 		int rc;
 		struct lnet_process_id id;
 		struct lnet_handle_md mdh;
@@ -1753,7 +1752,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
 		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
 		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
 		      libcfs_nid2str(nid), alive ? "up" : "down",
-		      cfs_duration_sec(cfs_time_sub(when, now)));
+		      cfs_duration_sec(when - now));
 		return -EINVAL;
 	}
 
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 315d067540c0..e4172311be68 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -331,8 +331,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 			int alive_cnt = peer->lp_alive_count;
 			int alive = peer->lp_alive;
 			int pingsent = !peer->lp_ping_notsent;
-			int last_ping = cfs_duration_sec(cfs_time_sub(now,
-						     peer->lp_ping_timestamp));
+			int last_ping = cfs_duration_sec(now - peer->lp_ping_timestamp);
 			int down_ni = 0;
 			struct lnet_route *rtr;
 
@@ -364,7 +363,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 					      nrefs, nrtrrefs, alive_cnt,
 					      alive ? "up" : "down", last_ping,
 					      pingsent,
-					      cfs_duration_sec(cfs_time_sub(deadline, now)),
+					      cfs_duration_sec(deadline - now),
 					      down_ni, libcfs_nid2str(nid));
 			LASSERT(tmpstr + tmpsiz - s > 0);
 		}
@@ -512,7 +511,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
 				unsigned long now = jiffies;
 				long delta;
 
-				delta = cfs_time_sub(now, peer->lp_last_alive);
+				delta = now - peer->lp_last_alive;
 				lastalive = cfs_duration_sec(delta);
 
 				/* No need to mess up peers contents with
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index 68e06e06857d..ea4944b9108b 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -500,8 +500,8 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
 
 		nd = crpc->crp_node;
 
-		dur = (long)cfs_time_sub(crpc->crp_stamp,
-		      (unsigned long)console_session.ses_id.ses_stamp);
+		dur = (long)(crpc->crp_stamp -
+			     (unsigned long)console_session.ses_id.ses_stamp);
 		jiffies_to_timeval(dur, &tv);
 
 		if (copy_to_user(&ent->rpe_peer, &nd->nd_id,
diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
index 1b2c5fc81358..1f9d5487e2f5 100644
--- a/drivers/staging/lustre/lnet/selftest/timer.c
+++ b/drivers/staging/lustre/lnet/selftest/timer.c
@@ -157,7 +157,7 @@ stt_check_timers(unsigned long *last)
 
 	while (cfs_time_aftereq(this_slot, *last)) {
 		expired += stt_expire_list(STTIMER_SLOT(this_slot), now);
-		this_slot = cfs_time_sub(this_slot, STTIMER_SLOTTIME);
+		this_slot = this_slot - STTIMER_SLOTTIME;
 	}
 
 	*last = now & STTIMER_SLOTTIMEMASK;
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index f4824d8ec741..d13db55b7242 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -556,7 +556,7 @@ struct ptlrpc_cli_req {
 	/** optional time limit for send attempts */
 	long				 cr_delay_limit;
 	/** time request was first queued */
-	time_t				 cr_queued_time;
+	unsigned long			 cr_queued_time;
 	/** request sent timeval */
 	struct timespec64		 cr_sent_tv;
 	/** time for request really sent out */
@@ -2253,8 +2253,7 @@ static inline int ptlrpc_req_get_repsize(struct ptlrpc_request *req)
 static inline int ptlrpc_send_limit_expired(struct ptlrpc_request *req)
 {
 	if (req->rq_delay_limit != 0 &&
-	    time_before(cfs_time_add(req->rq_queued_time,
-				     req->rq_delay_limit * HZ),
+	    time_before(req->rq_queued_time + req->rq_delay_limit * HZ,
 			jiffies)) {
 		return 1;
 	}
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index ab4dd15c8dd4..150e78c9eb68 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -326,8 +326,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
 	if (lock->l_granted_mode == LCK_PW &&
 	    !lock->l_readers && !lock->l_writers &&
 	    cfs_time_after(jiffies,
-			   cfs_time_add(lock->l_last_used,
-					10 * HZ))) {
+			   lock->l_last_used + 10 * HZ)) {
 		unlock_res_and_lock(lock);
 		if (ldlm_bl_to_thread_lock(ns, NULL, lock))
 			ldlm_handle_bl_callback(ns, NULL, lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 0e1b21c1f06d..6eb42f16040d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1176,13 +1176,12 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 	 * Despite of the LV, It doesn't make sense to keep the lock which
 	 * is unused for ns_max_age time.
 	 */
-	if (cfs_time_after(jiffies,
-			   cfs_time_add(lock->l_last_used, ns->ns_max_age)))
+	if (cfs_time_after(jiffies, lock->l_last_used + ns->ns_max_age))
 		return LDLM_POLICY_CANCEL_LOCK;
 
 	slv = ldlm_pool_get_slv(pl);
 	lvf = ldlm_pool_get_lvf(pl);
-	la = cfs_duration_sec(cfs_time_sub(cur, lock->l_last_used));
+	la = cfs_duration_sec(cur - lock->l_last_used);
 	lv = lvf * la * unused;
 
 	/* Inform pool about current CLV to see it via debugfs. */
@@ -1233,8 +1232,7 @@ static enum ldlm_policy_res ldlm_cancel_aged_policy(struct ldlm_namespace *ns,
 						    int count)
 {
 	if ((added >= count) &&
-	    time_before(jiffies,
-			cfs_time_add(lock->l_last_used, ns->ns_max_age)))
+	    time_before(jiffies, lock->l_last_used + ns->ns_max_age))
 		return LDLM_POLICY_KEEP_LOCK;
 
 	return LDLM_POLICY_CANCEL_LOCK;
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index c5dc894a4c1b..154d1721636e 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -327,8 +327,7 @@ int osc_object_is_contended(struct osc_object *obj)
 	 * I like copy-paste. the code is copied from
 	 * ll_file_is_contended.
 	 */
-	retry_time = cfs_time_add(obj->oo_contention_time,
-				  osc_contention_time * HZ);
+	retry_time = obj->oo_contention_time + osc_contention_time * HZ;
 	if (cfs_time_after(cur_time, retry_time)) {
 		osc_object_clear_contended(obj);
 		return 0;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 57c7db47e249..e836591c5936 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -141,8 +141,7 @@ static long pinger_check_timeout(unsigned long time)
 	}
 	mutex_unlock(&pinger_mutex);
 
-	return cfs_time_sub(cfs_time_add(time, timeout * HZ),
-					 jiffies);
+	return time + timeout * HZ - jiffies;
 }
 
 static bool ir_up;
@@ -238,8 +237,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 			/* obd_timeout might have changed */
 			if (imp->imp_pingable && imp->imp_next_ping &&
 			    cfs_time_after(imp->imp_next_ping,
-					   cfs_time_add(this_ping,
-							PING_INTERVAL * HZ)))
+					   this_ping + PING_INTERVAL * HZ))
 				ptlrpc_update_next_ping(imp, 0);
 		}
 		mutex_unlock(&pinger_mutex);
@@ -255,8 +253,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 		 */
 		CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
 		       time_to_next_wake,
-		       cfs_time_add(this_ping,
-				    PING_INTERVAL * HZ));
+		       this_ping + PING_INTERVAL * HZ);
 	} while (time_to_next_wake <= 0);
 
 	queue_delayed_work(pinger_wq, &ping_work,
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index fc29efbd9914..e71046db28e5 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -1153,7 +1153,7 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
 		spin_unlock(&svcpt->scp_at_lock);
 		return;
 	}
-	delay = cfs_time_sub(jiffies, svcpt->scp_at_checktime);
+	delay = jiffies - svcpt->scp_at_checktime;
 	svcpt->scp_at_check = 0;
 
 	if (array->paa_count == 0) {

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 12/17] staging: lustre: libcfs: discard cfs_time_after()
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

cfs_time_after() behaves exactly like time_after()
similarly cfs_time_aftereq() matches time_after_eq()

so discard the cfs versions.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/include/linux/libcfs/libcfs_time.h      |   14 ---------
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    4 +--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |    6 ++--
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    2 +
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   32 ++++++++++----------
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |    8 +++--
 drivers/staging/lustre/lnet/lnet/lib-move.c        |    4 +--
 drivers/staging/lustre/lnet/lnet/net_fault.c       |    8 +++--
 drivers/staging/lustre/lnet/lnet/router.c          |    6 ++--
 drivers/staging/lustre/lnet/selftest/conrpc.c      |    4 +--
 drivers/staging/lustre/lnet/selftest/timer.c       |    2 +
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    4 +--
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    4 +--
 drivers/staging/lustre/lustre/osc/osc_object.c     |    2 +
 drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    6 ++--
 16 files changed, 47 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
index 0ebbde4ec8e8..172a8872e3f3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
@@ -36,20 +36,6 @@
 
 #ifndef __LIBCFS_TIME_H__
 #define __LIBCFS_TIME_H__
-/*
- * generic time manipulation functions.
- */
-
-static inline int cfs_time_after(unsigned long t1, unsigned long t2)
-{
-	return time_before(t2, t1);
-}
-
-static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
-{
-	return time_before_eq(t2, t1);
-}
-
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 276bf486f64b..d0ce37d72571 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1522,7 +1522,7 @@ static int kiblnd_fmr_pool_is_idle(struct kib_fmr_pool *fpo, unsigned long now)
 		return 0;
 	if (fpo->fpo_failed)
 		return 1;
-	return cfs_time_aftereq(now, fpo->fpo_deadline);
+	return time_after_eq(now, fpo->fpo_deadline);
 }
 
 static int
@@ -1850,7 +1850,7 @@ static int kiblnd_pool_is_idle(struct kib_pool *pool, unsigned long now)
 		return 0;
 	if (pool->po_failed)
 		return 1;
-	return cfs_time_aftereq(now, pool->po_deadline);
+	return time_after_eq(now, pool->po_deadline);
 }
 
 void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index b18911d09e9a..ca6e09de0872 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -754,9 +754,9 @@ static inline int
 kiblnd_send_keepalive(struct kib_conn *conn)
 {
 	return (*kiblnd_tunables.kib_keepalive > 0) &&
-		cfs_time_after(jiffies, conn->ibc_last_send +
-			       msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
-						MSEC_PER_SEC));
+		time_after(jiffies, conn->ibc_last_send +
+			   msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
+					    MSEC_PER_SEC));
 }
 
 static inline int
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index f9761d8f2e3e..563ff5c972bf 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3141,7 +3141,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs)
 			LASSERT(tx->tx_waiting || tx->tx_sending);
 		}
 
-		if (cfs_time_aftereq(jiffies, tx->tx_deadline)) {
+		if (time_after_eq(jiffies, tx->tx_deadline)) {
 			CERROR("Timed out tx: %s, %lu seconds\n",
 			       kiblnd_queue2str(conn, txs),
 			       cfs_duration_sec(jiffies - tx->tx_deadline));
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 1ace54c9b133..8ead1e02e854 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -481,7 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 		LASSERT(conn->ksnc_tx_scheduled);
 		list_add_tail(&conn->ksnc_tx_list,
 			      &ksocknal_data.ksnd_enomem_conns);
-		if (!cfs_time_aftereq(jiffies + SOCKNAL_ENOMEM_RETRY,
+		if (!time_after_eq(jiffies + SOCKNAL_ENOMEM_RETRY,
 				   ksocknal_data.ksnd_reaper_waketime))
 			wake_up(&ksocknal_data.ksnd_reaper_waitq);
 
@@ -590,7 +590,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
 		case SOCKNAL_MATCH_YES: /* typed connection */
 			if (!typed || tnob > nob ||
 			    (tnob == nob && *ksocknal_tunables.ksnd_round_robin &&
-			     cfs_time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
+			     time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
 				typed = c;
 				tnob  = nob;
 			}
@@ -599,7 +599,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
 		case SOCKNAL_MATCH_MAY: /* fallback connection */
 			if (!fallback || fnob > nob ||
 			    (fnob == nob && *ksocknal_tunables.ksnd_round_robin &&
-			     cfs_time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
+			     time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
 				fallback = c;
 				fnob = nob;
 			}
@@ -745,7 +745,7 @@ ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
 			continue;
 
 		if (!(!route->ksnr_retry_interval || /* first attempt */
-		      cfs_time_aftereq(now, route->ksnr_timeout))) {
+		      time_after_eq(now, route->ksnr_timeout))) {
 			CDEBUG(D_NET,
 			       "Too soon to retry route %pI4h (cnted %d, interval %ld, %ld secs later)\n",
 			       &route->ksnr_ipaddr,
@@ -1823,7 +1823,7 @@ ksocknal_connect(struct ksock_route *route)
 
 		write_unlock_bh(&ksocknal_data.ksnd_global_lock);
 
-		if (cfs_time_aftereq(jiffies, deadline)) {
+		if (time_after_eq(jiffies, deadline)) {
 			rc = -ETIMEDOUT;
 			lnet_connect_console_error(rc, peer->ksnp_id.nid,
 						   route->ksnr_ipaddr,
@@ -2052,7 +2052,7 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
 	list_for_each_entry(route, &ksocknal_data.ksnd_connd_routes,
 			    ksnr_connd_list) {
 		if (!route->ksnr_retry_interval ||
-		    cfs_time_aftereq(now, route->ksnr_timeout))
+		    time_after_eq(now, route->ksnr_timeout))
 			return route;
 
 		if (*timeout_p == MAX_SCHEDULE_TIMEOUT ||
@@ -2224,8 +2224,8 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
 		}
 
 		if (conn->ksnc_rx_started &&
-		    cfs_time_aftereq(jiffies,
-				     conn->ksnc_rx_deadline)) {
+		    time_after_eq(jiffies,
+				  conn->ksnc_rx_deadline)) {
 			/* Timed out incomplete incoming message */
 			ksocknal_conn_addref(conn);
 			CNETERR("Timeout receiving from %s (%pI4h:%d), state %d wanted %zd left %d\n",
@@ -2240,8 +2240,8 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
 
 		if ((!list_empty(&conn->ksnc_tx_queue) ||
 		     conn->ksnc_sock->sk->sk_wmem_queued) &&
-		    cfs_time_aftereq(jiffies,
-				     conn->ksnc_tx_deadline)) {
+		    time_after_eq(jiffies,
+				  conn->ksnc_tx_deadline)) {
 			/*
 			 * Timed out messages queued for sending or
 			 * buffered in the socket's send buffer
@@ -2268,8 +2268,8 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer)
 	write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
 	list_for_each_entry_safe(tx, tmp, &peer->ksnp_tx_queue, tx_list) {
-		if (!cfs_time_aftereq(jiffies,
-				      tx->tx_deadline))
+		if (!time_after_eq(jiffies,
+				   tx->tx_deadline))
 			break;
 
 		list_del(&tx->tx_list);
@@ -2395,8 +2395,8 @@ ksocknal_check_peer_timeouts(int idx)
 			tx = list_entry(peer->ksnp_tx_queue.next,
 					struct ksock_tx, tx_list);
 
-			if (cfs_time_aftereq(jiffies,
-					     tx->tx_deadline)) {
+			if (time_after_eq(jiffies,
+					  tx->tx_deadline)) {
 				ksocknal_peer_addref(peer);
 				read_unlock(&ksocknal_data.ksnd_global_lock);
 
@@ -2413,8 +2413,8 @@ ksocknal_check_peer_timeouts(int idx)
 		tx_stale = NULL;
 		spin_lock(&peer->ksnp_lock);
 		list_for_each_entry(tx, &peer->ksnp_zc_req_list, tx_zc_list) {
-			if (!cfs_time_aftereq(jiffies,
-					      tx->tx_deadline))
+			if (!time_after_eq(jiffies,
+					   tx->tx_deadline))
 				break;
 			/* ignore the TX if connection is being closed */
 			if (tx->tx_conn->ksnc_closing)
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 2aeae0331ee0..129430e74d00 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -431,7 +431,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 	if (cdls) {
 		if (libcfs_console_ratelimit &&
 		    cdls->cdls_next &&		/* not first time ever */
-		    !cfs_time_after(jiffies, cdls->cdls_next)) {
+		    !time_after(jiffies, cdls->cdls_next)) {
 			/* skipping a console message */
 			cdls->cdls_count++;
 			if (tcd)
@@ -439,9 +439,9 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 			return 1;
 		}
 
-		if (cfs_time_after(jiffies,
-				   cdls->cdls_next + libcfs_console_max_delay +
-				   10 * HZ)) {
+		if (time_after(jiffies,
+			       cdls->cdls_next + libcfs_console_max_delay +
+			       10 * HZ)) {
 			/* last timeout was a long time ago */
 			cdls->cdls_delay /= libcfs_console_backoff * 4;
 		} else {
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index 5574d2148c9d..60464135161b 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -520,11 +520,11 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
 	 * ignore the initial assumed death (see lnet_peers_start_down()).
 	 */
 	if (!lp->lp_alive && lp->lp_alive_count > 0 &&
-	    cfs_time_aftereq(lp->lp_timestamp, lp->lp_last_alive))
+	    time_after_eq(lp->lp_timestamp, lp->lp_last_alive))
 		return 0;
 
 	deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout * HZ;
-	alive = cfs_time_after(deadline, now);
+	alive = time_after(deadline, now);
 
 	/* Update obsolete lp_alive except for routers assumed to be dead
 	 * initially, because router checker would update aliveness in this
diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
index 05d7b754815a..0066394b0bb0 100644
--- a/drivers/staging/lustre/lnet/lnet/net_fault.c
+++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
@@ -309,9 +309,9 @@ drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
 		unsigned long now = jiffies;
 
 		rule->dr_stat.fs_count++;
-		drop = cfs_time_aftereq(now, rule->dr_drop_time);
+		drop = time_after_eq(now, rule->dr_drop_time);
 		if (drop) {
-			if (cfs_time_after(now, rule->dr_time_base))
+			if (time_after(now, rule->dr_time_base))
 				rule->dr_time_base = now;
 
 			rule->dr_drop_time = rule->dr_time_base +
@@ -475,9 +475,9 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
 		unsigned long now = jiffies;
 
 		rule->dl_stat.fs_count++;
-		delay = cfs_time_aftereq(now, rule->dl_delay_time);
+		delay = time_after_eq(now, rule->dl_delay_time);
 		if (delay) {
-			if (cfs_time_after(now, rule->dl_time_base))
+			if (time_after(now, rule->dl_time_base))
 				rule->dl_time_base = now;
 
 			rule->dl_delay_time = rule->dl_time_base +
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index c72d4f4454ec..8baf35d56ca7 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -982,7 +982,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
 	lnet_peer_addref_locked(rtr);
 
 	if (rtr->lp_ping_deadline && /* ping timed out? */
-	    cfs_time_after(now, rtr->lp_ping_deadline))
+	    time_after(now, rtr->lp_ping_deadline))
 		lnet_notify_locked(rtr, 1, 0, now);
 
 	/* Run any outstanding notifications */
@@ -1010,7 +1010,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
 	       rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
 
 	if (secs && !rtr->lp_ping_notsent &&
-	    cfs_time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
+	    time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
 		int rc;
 		struct lnet_process_id id;
 		struct lnet_handle_md mdh;
@@ -1748,7 +1748,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
 	}
 
 	/* can't do predictions... */
-	if (cfs_time_after(when, now)) {
+	if (time_after(when, now)) {
 		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
 		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
 		      libcfs_nid2str(nid), alive ? "up" : "down",
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index ea4944b9108b..8c237758c3eb 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -315,7 +315,7 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
 			continue;
 
 		nd = crpc->crp_node;
-		if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
+		if (time_after(nd->nd_stamp, crpc->crp_stamp))
 			continue;
 
 		nd->nd_stamp = crpc->crp_stamp;
@@ -404,7 +404,7 @@ lstcon_rpc_get_reply(struct lstcon_rpc *crpc, struct srpc_msg **msgpp)
 		crpc->crp_unpacked = 1;
 	}
 
-	if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
+	if (time_after(nd->nd_stamp, crpc->crp_stamp))
 		return 0;
 
 	nd->nd_stamp = crpc->crp_stamp;
diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
index 1f9d5487e2f5..582f252b3e12 100644
--- a/drivers/staging/lustre/lnet/selftest/timer.c
+++ b/drivers/staging/lustre/lnet/selftest/timer.c
@@ -155,7 +155,7 @@ stt_check_timers(unsigned long *last)
 
 	spin_lock(&stt_data.stt_lock);
 
-	while (cfs_time_aftereq(this_slot, *last)) {
+	while (time_after_eq(this_slot, *last)) {
 		expired += stt_expire_list(STTIMER_SLOT(this_slot), now);
 		this_slot = this_slot - STTIMER_SLOTTIME;
 	}
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index 150e78c9eb68..942d34f7a44c 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -325,8 +325,8 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
 	lock_res_and_lock(lock);
 	if (lock->l_granted_mode == LCK_PW &&
 	    !lock->l_readers && !lock->l_writers &&
-	    cfs_time_after(jiffies,
-			   lock->l_last_used + 10 * HZ)) {
+	    time_after(jiffies,
+		       lock->l_last_used + 10 * HZ)) {
 		unlock_res_and_lock(lock);
 		if (ldlm_bl_to_thread_lock(ns, NULL, lock))
 			ldlm_handle_bl_callback(ns, NULL, lock);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 647e85b16c02..187095022fb1 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -116,7 +116,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
 			   (s64)lock->l_last_activity,
 			   (s64)(ktime_get_real_seconds() -
 				 lock->l_last_activity));
-		if (cfs_time_after(jiffies, next_dump)) {
+		if (time_after(jiffies, next_dump)) {
 			last_dump = next_dump;
 			next_dump = jiffies + 300 * HZ;
 			ldlm_namespace_dump(D_DLMTRACE,
@@ -1176,7 +1176,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 	 * Despite of the LV, It doesn't make sense to keep the lock which
 	 * is unused for ns_max_age time.
 	 */
-	if (cfs_time_after(jiffies, lock->l_last_used + ns->ns_max_age))
+	if (time_after(jiffies, lock->l_last_used + ns->ns_max_age))
 		return LDLM_POLICY_CANCEL_LOCK;
 
 	slv = ldlm_pool_get_slv(pl);
diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
index 154d1721636e..84240181c7ea 100644
--- a/drivers/staging/lustre/lustre/osc/osc_object.c
+++ b/drivers/staging/lustre/lustre/osc/osc_object.c
@@ -328,7 +328,7 @@ int osc_object_is_contended(struct osc_object *obj)
 	 * ll_file_is_contended.
 	 */
 	retry_time = obj->oo_contention_time + osc_contention_time * HZ;
-	if (cfs_time_after(cur_time, retry_time)) {
+	if (time_after(cur_time, retry_time)) {
 		osc_object_clear_contended(obj);
 		return 0;
 	}
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 04d801f11ace..0038e555e905 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -748,7 +748,7 @@ static int osc_should_shrink_grant(struct client_obd *client)
 	     OBD_CONNECT_GRANT_SHRINK) == 0)
 		return 0;
 
-	if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) {
+	if (time_after_eq(time, next_shrink - 5 * CFS_TICK)) {
 		/* Get the current RPC size directly, instead of going via:
 		 * cli_brw_size(obd->u.cli.cl_import->imp_obd->obd_self_export)
 		 * Keep comment here so that it can be found by searching.
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 7057b4447035..3f17c673d1b8 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -180,7 +180,7 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp,
 
 	imp->imp_force_verify = 0;
 
-	if (cfs_time_aftereq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
+	if (time_after_eq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
 	    !force) {
 		spin_unlock(&imp->imp_lock);
 		return;
@@ -236,8 +236,8 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 			ptlrpc_pinger_process_import(imp, this_ping);
 			/* obd_timeout might have changed */
 			if (imp->imp_pingable && imp->imp_next_ping &&
-			    cfs_time_after(imp->imp_next_ping,
-					   this_ping + PING_INTERVAL * HZ))
+			    time_after(imp->imp_next_ping,
+				       this_ping + PING_INTERVAL * HZ))
 				ptlrpc_update_next_ping(imp, 0);
 		}
 		mutex_unlock(&pinger_mutex);

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 14/17] staging: lustre: discard cfs_duration_sec()
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

cfs_duration_sec() simply divides by HZ.
It is mostly used to report durations in debug messages.
Remove and just use X/HZ.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/include/linux/libcfs/linux/linux-time.h |    5 -----
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    2 +-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    5 ++---
 .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 ++--
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |    4 ++--
 drivers/staging/lustre/lnet/libcfs/debug.c         |    2 +-
 drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
 drivers/staging/lustre/lnet/lnet/router_proc.c     |    6 +++---
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    2 +-
 9 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ecb2126a9e6f..9a353c6cb85a 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -60,11 +60,6 @@
  * Generic kernel stuff
  */
 
-static inline long cfs_duration_sec(long d)
-{
-	return d / msecs_to_jiffies(MSEC_PER_SEC);
-}
-
 static inline int cfs_time_before_64(u64 t1, u64 t2)
 {
 	return (__s64)t2 - (__s64)t1 > 0;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index d0ce37d72571..959e119384df 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -1068,7 +1068,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,
 
 	CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
 	       libcfs_nid2str(nid), peer,
-	       last_alive ? cfs_duration_sec(now - last_alive) : -1);
+	       last_alive ? (now - last_alive) / HZ : -1);
 }
 
 static void kiblnd_free_pages(struct kib_pages *p)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 563ff5c972bf..b4a182d87ae7 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -3144,7 +3144,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs)
 		if (time_after_eq(jiffies, tx->tx_deadline)) {
 			CERROR("Timed out tx: %s, %lu seconds\n",
 			       kiblnd_queue2str(conn, txs),
-			       cfs_duration_sec(jiffies - tx->tx_deadline));
+			       (jiffies - tx->tx_deadline) / HZ);
 			return 1;
 		}
 	}
@@ -3206,8 +3206,7 @@ kiblnd_check_conns(int idx)
 			if (timedout) {
 				CERROR("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n",
 				       libcfs_nid2str(peer->ibp_nid),
-				       cfs_duration_sec(jiffies -
-							peer->ibp_last_alive),
+				       (jiffies - peer->ibp_last_alive) / HZ,
 				       conn->ibc_credits,
 				       conn->ibc_outstanding_credits,
 				       conn->ibc_reserved_credits);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 16c1ab0b0bd9..79b98cdd0f9d 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
 		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
 		       &conn->ksnc_ipaddr, conn->ksnc_port,
 		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
-		       cfs_duration_sec(jiffies - last_rcv));
+		       (jiffies - last_rcv) / HZ);
 		lnet_finalize(conn->ksnc_peer->ksnp_ni,
 			      conn->ksnc_cookie, -EIO);
 		break;
@@ -1870,7 +1870,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
 
 	CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago, connect %d\n",
 	       libcfs_nid2str(nid), peer,
-	       last_alive ? cfs_duration_sec(now - last_alive) : -1,
+	       last_alive ? (now - last_alive) / HZ : -1,
 	       connect);
 
 	if (!connect)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index 8ead1e02e854..14450fd5957a 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -751,7 +751,7 @@ ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
 			       &route->ksnr_ipaddr,
 			       route->ksnr_connected,
 			       route->ksnr_retry_interval,
-			       cfs_duration_sec(route->ksnr_timeout - now));
+			       (route->ksnr_timeout - now) / HZ);
 			continue;
 		}
 
@@ -2439,7 +2439,7 @@ ksocknal_check_peer_timeouts(int idx)
 
 		CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n",
 		       n, libcfs_nid2str(peer->ksnp_id.nid), tx_stale,
-		       cfs_duration_sec(jiffies - deadline),
+		       (jiffies - deadline) / HZ,
 		       resid, conn->ksnc_sock->sk->sk_wmem_queued);
 
 		ksocknal_close_conn_and_siblings(conn, -ETIMEDOUT);
diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c
index 1371224a8cb9..5862f0730dd0 100644
--- a/drivers/staging/lustre/lnet/libcfs/debug.c
+++ b/drivers/staging/lustre/lnet/libcfs/debug.c
@@ -126,7 +126,7 @@ static int param_get_delay(char *buffer, const struct kernel_param *kp)
 {
 	unsigned int d = *(unsigned int *)kp->arg;
 
-	return sprintf(buffer, "%u", (unsigned int)cfs_duration_sec(d * 100));
+	return sprintf(buffer, "%u", (unsigned int)(d * 100) / HZ);
 }
 
 unsigned int libcfs_console_max_delay;
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index 8baf35d56ca7..6267d5e4bbd6 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -1752,7 +1752,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
 		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
 		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
 		      libcfs_nid2str(nid), alive ? "up" : "down",
-		      cfs_duration_sec(when - now));
+		      (when - now) / HZ);
 		return -EINVAL;
 	}
 
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index e4172311be68..015dccbc4a58 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -331,7 +331,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 			int alive_cnt = peer->lp_alive_count;
 			int alive = peer->lp_alive;
 			int pingsent = !peer->lp_ping_notsent;
-			int last_ping = cfs_duration_sec(now - peer->lp_ping_timestamp);
+			int last_ping = (now - peer->lp_ping_timestamp) / HZ;
 			int down_ni = 0;
 			struct lnet_route *rtr;
 
@@ -363,7 +363,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
 					      nrefs, nrtrrefs, alive_cnt,
 					      alive ? "up" : "down", last_ping,
 					      pingsent,
-					      cfs_duration_sec(deadline - now),
+					      (deadline - now) / HZ,
 					      down_ni, libcfs_nid2str(nid));
 			LASSERT(tmpstr + tmpsiz - s > 0);
 		}
@@ -512,7 +512,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
 				long delta;
 
 				delta = now - peer->lp_last_alive;
-				lastalive = cfs_duration_sec(delta);
+				lastalive = (delta) / HZ;
 
 				/* No need to mess up peers contents with
 				 * arbitrarily long integers - it suffices to
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 187095022fb1..f573de9cf45d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1181,7 +1181,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
 
 	slv = ldlm_pool_get_slv(pl);
 	lvf = ldlm_pool_get_lvf(pl);
-	la = cfs_duration_sec(cur - lock->l_last_used);
+	la = (cur - lock->l_last_used) / HZ;
 	lv = lvf * la * unused;
 
 	/* Inform pool about current CLV to see it via debugfs. */

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 15/17] staging: lustre: discard cfs_time_before_64()
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

cfs_time_before_64 is the same as time_before64()
similarly cfs_time_beforeq_64() matsches time_before_eq64()
So just use the standard interfaces.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/include/linux/libcfs/linux/linux-time.h |   14 --------------
 drivers/staging/lustre/lustre/include/obd_class.h  |    4 ++--
 drivers/staging/lustre/lustre/ptlrpc/import.c      |    4 ++--
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index 9a353c6cb85a..ecdebccf2b44 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -56,20 +56,6 @@
 
 #include <linux/jiffies.h>
 
-/*
- * Generic kernel stuff
- */
-
-static inline int cfs_time_before_64(u64 t1, u64 t2)
-{
-	return (__s64)t2 - (__s64)t1 > 0;
-}
-
-static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
-{
-	return (__s64)t2 - (__s64)t1 >= 0;
-}
-
 /*
  * One jiffy
  */
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 7cfc3c8d100c..176b63e2c9a7 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -932,7 +932,7 @@ static inline int obd_statfs_async(struct obd_export *exp,
 
 	CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n",
 	       obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age);
-	if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+	if (time_before64(obd->obd_osfs_age, max_age)) {
 		rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
 	} else {
 		CDEBUG(D_SUPER,
@@ -992,7 +992,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
 
 	CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n",
 	       obd->obd_osfs_age, max_age);
-	if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
+	if (time_before64(obd->obd_osfs_age, max_age)) {
 		rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
 		if (rc == 0) {
 			spin_lock(&obd->obd_osfs_lock);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index dd4fd54128dd..537a9e2ed467 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -463,7 +463,7 @@ static int import_select_connection(struct obd_import *imp)
 		 * the last successful attempt, go with this one
 		 */
 		if ((conn->oic_last_attempt == 0) ||
-		    cfs_time_beforeq_64(conn->oic_last_attempt,
+		    time_before_eq64(conn->oic_last_attempt,
 					imp->imp_last_success_conn)) {
 			imp_conn = conn;
 			tried_all = 0;
@@ -476,7 +476,7 @@ static int import_select_connection(struct obd_import *imp)
 		 */
 		if (!imp_conn)
 			imp_conn = conn;
-		else if (cfs_time_before_64(conn->oic_last_attempt,
+		else if (time_before64(conn->oic_last_attempt,
 					    imp_conn->oic_last_attempt))
 			imp_conn = conn;
 	}

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 16/17] staging: lustre: discard linux-time.h
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

Very little is left in linux-time.h.
Move CFS_TICK to libcfs.h discard the test.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |    5 ++
 .../lustre/include/linux/libcfs/linux/libcfs.h     |    1 
 .../lustre/include/linux/libcfs/linux/linux-time.h |   66 --------------------
 drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    2 -
 4 files changed, 6 insertions(+), 68 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 3d3fa52858e5..f183f31da387 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -52,6 +52,11 @@
 
 #define LOWEST_BIT_SET(x)       ((x) & ~((x) - 1))
 
+/*
+ * One jiffy
+ */
+#define CFS_TICK		(1UL)
+
 /*
  * Lustre Error Checksum: calculates checksum
  * of Hex number by XORing each bit.
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index 30e333af8d0d..c39c34d74382 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -80,7 +80,6 @@
 #include <linux/uaccess.h>
 #include <stdarg.h>
 #include "linux-cpu.h"
-#include "linux-time.h"
 
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
 
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
deleted file mode 100644
index ecdebccf2b44..000000000000
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/linux/linux-time.h
- *
- * Implementation of portable time API for Linux (kernel and user-level).
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#ifndef __LIBCFS_LINUX_LINUX_TIME_H__
-#define __LIBCFS_LINUX_LINUX_TIME_H__
-
-#ifndef __LIBCFS_LIBCFS_H__
-#error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
-#endif
-
-#define ONE_BILLION ((u_int64_t)1000000000)
-#define ONE_MILLION 1000000
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/time.h>
-#include <asm/div64.h>
-
-/*
- * post 2.5 kernels.
- */
-
-#include <linux/jiffies.h>
-
-/*
- * One jiffy
- */
-#define CFS_TICK		(1UL)
-
-#define CFS_DURATION_T	  "%ld"
-
-#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 3f17c673d1b8..89eef8ec7df4 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -251,7 +251,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 		 * we will SKIP the next ping at next_ping, and the
 		 * ping will get sent 2 timeouts from now!  Beware.
 		 */
-		CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
+		CDEBUG(D_INFO, "next wakeup in %ld (%ld)\n",
 		       time_to_next_wake,
 		       this_ping + PING_INTERVAL * HZ);
 	} while (time_to_next_wake <= 0);

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

This wrapper is only used once, so open-code it as max().

This allows us to remove the libcfs_time.h include file.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |    1 
 .../lustre/include/linux/libcfs/libcfs_time.h      |   50 --------------------
 .../lustre/include/linux/libcfs/linux/linux-time.h |    2 -
 drivers/staging/lustre/lustre/ptlrpc/import.c      |    4 +-
 4 files changed, 3 insertions(+), 54 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 3b751c436b3d..3d3fa52858e5 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -43,7 +43,6 @@
 #include <linux/libcfs/libcfs_private.h>
 #include <linux/libcfs/libcfs_cpu.h>
 #include <linux/libcfs/libcfs_prim.h>
-#include <linux/libcfs/libcfs_time.h>
 #include <linux/libcfs/libcfs_string.h>
 #include <linux/libcfs/libcfs_hash.h>
 #include <linux/libcfs/libcfs_fail.h>
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
deleted file mode 100644
index 172a8872e3f3..000000000000
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfs_time.h
- *
- * Time functions.
- *
- */
-
-#ifndef __LIBCFS_TIME_H__
-#define __LIBCFS_TIME_H__
-/*
- * return valid time-out based on user supplied one. Currently we only check
- * that time-out is not shorted than allowed.
- */
-static inline long cfs_timeout_cap(long timeout)
-{
-	if (timeout < CFS_TICK)
-		timeout = CFS_TICK;
-	return timeout;
-}
-
-#endif
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
index ff3aae2f1231..ecb2126a9e6f 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
@@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
 /*
  * One jiffy
  */
-#define CFS_TICK		(1)
+#define CFS_TICK		(1UL)
 
 #define CFS_DURATION_T	  "%ld"
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index 4a9d1f189d01..dd4fd54128dd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
 	}
 
 	if (ptlrpc_import_in_recovery(imp)) {
-		long timeout;
+		unsigned long timeout;
 
 		if (AT_OFF) {
 			if (imp->imp_server_timeout)
@@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
 
 		if (wait_event_idle_timeout(imp->imp_recovery_waitq,
 					    !ptlrpc_import_in_recovery(imp),
-					    cfs_timeout_cap(timeout)) == 0)
+					    max(timeout, CFS_TICK)) == 0)
 			l_wait_event_abortable(
 				imp->imp_recovery_waitq,
 				!ptlrpc_import_in_recovery(imp));

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 17/17] staging: lustre: remove cruft from libcfs/linux/libcfs.h
@ 2018-03-29  4:26   ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-03-29  4:26 UTC (permalink / raw)
  To: Oleg Drokin, Greg Kroah-Hartman, James Simmons, Andreas Dilger
  Cc: Linux Kernel Mailing List, Lustre Development List

These defines are unused or nearly unused, and do not
help at all.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/libcfs/curproc.h  |    2 --
 .../lustre/include/linux/libcfs/linux/libcfs.h     |   17 -----------------
 drivers/staging/lustre/lnet/libcfs/tracefile.c     |    2 +-
 3 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h
index 4702956805a6..d6e4f47b5daf 100644
--- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
+++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
@@ -43,8 +43,6 @@
 /*
  * Plus, platform-specific constant
  *
- * CFS_CURPROC_COMM_MAX,
- *
  * and opaque scalar type
  *
  * kernel_cap_t
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index c39c34d74382..0dbd01617865 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -81,8 +81,6 @@
 #include <stdarg.h>
 #include "linux-cpu.h"
 
-#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
-
 #if !defined(__x86_64__)
 # ifdef __ia64__
 #  define CDEBUG_STACK() (THREAD_SIZE -				 \
@@ -114,19 +112,4 @@ do {								    \
 #define CDEBUG_STACK() (0L)
 #endif /* __x86_64__ */
 
-#define __current_nesting_level() (0)
-
-/**
- * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
- *
- * Implementation is in linux-curproc.c
- */
-#define CFS_CURPROC_COMM_MAX (sizeof((struct task_struct *)0)->comm)
-
-#include <linux/capability.h>
-
-#ifndef WITH_WATCHDOG
-#define WITH_WATCHDOG
-#endif
-
 #endif /* _LINUX_LIBCFS_H */
diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
index 129430e74d00..514e1845740e 100644
--- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
@@ -328,7 +328,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
 		goto console;
 	}
 
-	depth = __current_nesting_level();
+	depth = 0;
 	known_size = strlen(file) + 1 + depth;
 	if (msgdata->msg_fn)
 		known_size += strlen(msgdata->msg_fn) + 1;

^ permalink raw reply related	[flat|nested] 86+ messages in thread

* Re: [PATCH 01/17] staging: lustre: remove invariant in cl_io_read_ahead()
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 18:56     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:56 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> This invariant can fail as ci_type is somtimes CIS_INIT.
> 
> According to Jinshan Xiong, or of the most recent significant
> change to this code, "We should get rid of it."
> 
> So do that.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Fixes: 1e1db2a97be5 ("staging: lustre: clio: Revise read ahead implementation")
> Cc: Jinshan Xiong <jinshan.xiong@intel.com>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/cl_io.c |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c
> index ab84e011b560..fcdae6029258 100644
> --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
> +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
> @@ -599,7 +599,6 @@ int cl_io_read_ahead(const struct lu_env *env, struct cl_io *io,
>  	int		       result = 0;
>  
>  	LINVRNT(io->ci_type == CIT_READ || io->ci_type == CIT_FAULT);
> -	LINVRNT(io->ci_state == CIS_IO_GOING || io->ci_state == CIS_LOCKED);
>  	LINVRNT(cl_io_invariant(io));
>  
>  	cl_io_for_each(scan, io) {
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 01/17] staging: lustre: remove invariant in cl_io_read_ahead()
@ 2018-03-30 18:56     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:56 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> This invariant can fail as ci_type is somtimes CIS_INIT.
> 
> According to Jinshan Xiong, or of the most recent significant
> change to this code, "We should get rid of it."
> 
> So do that.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Fixes: 1e1db2a97be5 ("staging: lustre: clio: Revise read ahead implementation")
> Cc: Jinshan Xiong <jinshan.xiong@intel.com>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/cl_io.c |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c
> index ab84e011b560..fcdae6029258 100644
> --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
> +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
> @@ -599,7 +599,6 @@ int cl_io_read_ahead(const struct lu_env *env, struct cl_io *io,
>  	int		       result = 0;
>  
>  	LINVRNT(io->ci_type == CIT_READ || io->ci_type == CIT_FAULT);
> -	LINVRNT(io->ci_state == CIS_IO_GOING || io->ci_state == CIS_LOCKED);
>  	LINVRNT(cl_io_invariant(io));
>  
>  	cl_io_for_each(scan, io) {
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 02/17] staging: lustre: remove unused ldlm_completion_ast_async()
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 18:57     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:57 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> This function is unused.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/lustre_dlm.h |    1 -
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   23 --------------------
>  2 files changed, 24 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> index 239aa2b1268f..7407acf60cf8 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> @@ -1227,7 +1227,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
>   * processing.
>   * @{
>   */
> -int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data);
>  int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data);
>  /** @} ldlm_local_ast */
>  
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index c3c9186b74ce..be43958e4090 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -191,29 +191,6 @@ static int ldlm_completion_tail(struct ldlm_lock *lock, void *data)
>  	return result;
>  }
>  
> -/**
> - * Implementation of ->l_completion_ast() for a client, that doesn't wait
> - * until lock is granted. Suitable for locks enqueued through ptlrpcd, of
> - * other threads that cannot block for long.
> - */
> -int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data)
> -{
> -	if (flags == LDLM_FL_WAIT_NOREPROC) {
> -		LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock");
> -		return 0;
> -	}
> -
> -	if (!(flags & LDLM_FL_BLOCKED_MASK)) {
> -		wake_up(&lock->l_waitq);
> -		return ldlm_completion_tail(lock, data);
> -	}
> -
> -	LDLM_DEBUG(lock,
> -		   "client-side enqueue returned a blocked lock, going forward");
> -	return 0;
> -}
> -EXPORT_SYMBOL(ldlm_completion_ast_async);
> -
>  /**
>   * Generic LDLM "completion" AST. This is called in several cases:
>   *
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 02/17] staging: lustre: remove unused ldlm_completion_ast_async()
@ 2018-03-30 18:57     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:57 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> This function is unused.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/lustre_dlm.h |    1 -
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   23 --------------------
>  2 files changed, 24 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> index 239aa2b1268f..7407acf60cf8 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> @@ -1227,7 +1227,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
>   * processing.
>   * @{
>   */
> -int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data);
>  int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data);
>  /** @} ldlm_local_ast */
>  
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index c3c9186b74ce..be43958e4090 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -191,29 +191,6 @@ static int ldlm_completion_tail(struct ldlm_lock *lock, void *data)
>  	return result;
>  }
>  
> -/**
> - * Implementation of ->l_completion_ast() for a client, that doesn't wait
> - * until lock is granted. Suitable for locks enqueued through ptlrpcd, of
> - * other threads that cannot block for long.
> - */
> -int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data)
> -{
> -	if (flags == LDLM_FL_WAIT_NOREPROC) {
> -		LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock");
> -		return 0;
> -	}
> -
> -	if (!(flags & LDLM_FL_BLOCKED_MASK)) {
> -		wake_up(&lock->l_waitq);
> -		return ldlm_completion_tail(lock, data);
> -	}
> -
> -	LDLM_DEBUG(lock,
> -		   "client-side enqueue returned a blocked lock, going forward");
> -	return 0;
> -}
> -EXPORT_SYMBOL(ldlm_completion_ast_async);
> -
>  /**
>   * Generic LDLM "completion" AST. This is called in several cases:
>   *
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 04/17] staging: lustre: remove unused hash tables.
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 18:57     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:57 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> exp_lock_hash and exp_flock_hash are unused in
> the client, so remove all references.
> 
> Also remove unused hashtable size definitions.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/lustre_dlm.h |   10 -------
>  .../staging/lustre/lustre/include/lustre_export.h  |    7 -----
>  .../staging/lustre/lustre/include/obd_support.h    |   18 -------------
>  drivers/staging/lustre/lustre/ldlm/ldlm_flock.c    |   11 +-------
>  drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   14 ----------
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   27 +-------------------
>  drivers/staging/lustre/lustre/obdclass/genops.c    |    2 -
>  7 files changed, 3 insertions(+), 86 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> index 7407acf60cf8..5a355fbab401 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> @@ -629,16 +629,6 @@ struct ldlm_lock {
>  	 * Tree node for ldlm_extent.
>  	 */
>  	struct ldlm_interval	*l_tree_node;
> -	/**
> -	 * Per export hash of locks.
> -	 * Protected by per-bucket exp->exp_lock_hash locks.
> -	 */
> -	struct hlist_node	l_exp_hash;
> -	/**
> -	 * Per export hash of flock locks.
> -	 * Protected by per-bucket exp->exp_flock_hash locks.
> -	 */
> -	struct hlist_node	l_exp_flock_hash;
>  	/**
>  	 * Requested mode.
>  	 * Protected by lr_lock.
> diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h
> index 40cd168ed2ea..19ce13bc8ee6 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_export.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_export.h
> @@ -102,13 +102,6 @@ struct obd_export {
>  	struct ptlrpc_connection *exp_connection;
>  	/** Connection count value from last successful reconnect rpc */
>  	__u32		     exp_conn_cnt;
> -	/** Hash list of all ldlm locks granted on this export */
> -	struct cfs_hash	       *exp_lock_hash;
> -	/**
> -	 * Hash list for Posix lock deadlock detection, added with
> -	 * ldlm_lock::l_exp_flock_hash.
> -	 */
> -	struct cfs_hash	       *exp_flock_hash;
>  	struct list_head		exp_outstanding_replies;
>  	struct list_head		exp_uncommitted_replies;
>  	spinlock_t		  exp_uncommitted_replies_lock;
> diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
> index 8595091b8b86..eb2d6cb6b40b 100644
> --- a/drivers/staging/lustre/lustre/include/obd_support.h
> +++ b/drivers/staging/lustre/lustre/include/obd_support.h
> @@ -67,27 +67,9 @@ extern char obd_jobid_var[];
>  #define HASH_UUID_BKT_BITS 5
>  #define HASH_UUID_CUR_BITS 7
>  #define HASH_UUID_MAX_BITS 12
> -#define HASH_NID_BKT_BITS 5
> -#define HASH_NID_CUR_BITS 7
> -#define HASH_NID_MAX_BITS 12
> -#define HASH_NID_STATS_BKT_BITS 5
> -#define HASH_NID_STATS_CUR_BITS 7
> -#define HASH_NID_STATS_MAX_BITS 12
> -#define HASH_LQE_BKT_BITS 5
> -#define HASH_LQE_CUR_BITS 7
> -#define HASH_LQE_MAX_BITS 12
>  #define HASH_CONN_BKT_BITS 5
>  #define HASH_CONN_CUR_BITS 5
>  #define HASH_CONN_MAX_BITS 15
> -#define HASH_EXP_LOCK_BKT_BITS  5
> -#define HASH_EXP_LOCK_CUR_BITS  7
> -#define HASH_EXP_LOCK_MAX_BITS  16
> -#define HASH_CL_ENV_BKT_BITS    5
> -#define HASH_CL_ENV_BITS	10
> -#define HASH_JOB_STATS_BKT_BITS 5
> -#define HASH_JOB_STATS_CUR_BITS 7
> -#define HASH_JOB_STATS_MAX_BITS 12
> -
>  /* Timeout definitions */
>  #define OBD_TIMEOUT_DEFAULT	     100
>  /* Time to wait for all clients to reconnect during recovery (hard limit) */
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> index 411b540b96d9..94f3b1e49896 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> @@ -83,9 +83,6 @@ ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode)
>  	LDLM_DEBUG(lock, "%s(mode: %d)",
>  		   __func__, mode);
>  
> -	/* Safe to not lock here, since it should be empty anyway */
> -	LASSERT(hlist_unhashed(&lock->l_exp_flock_hash));
> -
>  	list_del_init(&lock->l_res_link);
>  
>  	/* client side - set a flag to prevent sending a CANCEL */
> @@ -263,15 +260,9 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req)
>  		lock->l_policy_data.l_flock.start =
>  			new->l_policy_data.l_flock.end + 1;
>  		new2->l_conn_export = lock->l_conn_export;
> -		if (lock->l_export) {
> +		if (lock->l_export)
>  			new2->l_export = class_export_lock_get(lock->l_export,
>  							       new2);
> -			if (new2->l_export->exp_lock_hash &&
> -			    hlist_unhashed(&new2->l_exp_hash))
> -				cfs_hash_add(new2->l_export->exp_lock_hash,
> -					     &new2->l_remote_handle,
> -					     &new2->l_exp_hash);
> -		}
>  		ldlm_lock_addref_internal_nolock(new2,
>  						 lock->l_granted_mode);
>  
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> index 95bea351d21d..b8fd778d9832 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> @@ -318,18 +318,6 @@ static int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
>  	}
>  	ldlm_set_destroyed(lock);
>  
> -	if (lock->l_export && lock->l_export->exp_lock_hash) {
> -		/* NB: it's safe to call cfs_hash_del() even lock isn't
> -		 * in exp_lock_hash.
> -		 */
> -		/* In the function below, .hs_keycmp resolves to
> -		 * ldlm_export_lock_keycmp()
> -		 */
> -		/* coverity[overrun-buffer-val] */
> -		cfs_hash_del(lock->l_export->exp_lock_hash,
> -			     &lock->l_remote_handle, &lock->l_exp_hash);
> -	}
> -
>  	ldlm_lock_remove_from_lru(lock);
>  	class_handle_unhash(&lock->l_handle);
>  
> @@ -419,8 +407,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
>  	lock->l_blocking_lock = NULL;
>  	INIT_LIST_HEAD(&lock->l_sl_mode);
>  	INIT_LIST_HEAD(&lock->l_sl_policy);
> -	INIT_HLIST_NODE(&lock->l_exp_hash);
> -	INIT_HLIST_NODE(&lock->l_exp_flock_hash);
>  
>  	lprocfs_counter_incr(ldlm_res_to_ns(resource)->ns_stats,
>  			     LDLM_NSS_LOCKS);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index be43958e4090..8e79f5e073ff 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -405,19 +405,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
>  	cleanup_phase = 0;
>  
>  	lock_res_and_lock(lock);
> -	/* Key change rehash lock in per-export hash with new key */
> -	if (exp->exp_lock_hash) {
> -		/* In the function below, .hs_keycmp resolves to
> -		 * ldlm_export_lock_keycmp()
> -		 */
> -		/* coverity[overrun-buffer-val] */
> -		cfs_hash_rehash_key(exp->exp_lock_hash,
> -				    &lock->l_remote_handle,
> -				    &reply->lock_handle,
> -				    &lock->l_exp_hash);
> -	} else {
> -		lock->l_remote_handle = reply->lock_handle;
> -	}
> +	lock->l_remote_handle = reply->lock_handle;
>  
>  	*flags = ldlm_flags_from_wire(reply->lock_flags);
>  	lock->l_flags |= ldlm_flags_from_wire(reply->lock_flags &
> @@ -1884,18 +1872,7 @@ static int replay_lock_interpret(const struct lu_env *env,
>  
>  	/* Key change rehash lock in per-export hash with new key */
>  	exp = req->rq_export;
> -	if (exp && exp->exp_lock_hash) {
> -		/* In the function below, .hs_keycmp resolves to
> -		 * ldlm_export_lock_keycmp()
> -		 */
> -		/* coverity[overrun-buffer-val] */
> -		cfs_hash_rehash_key(exp->exp_lock_hash,
> -				    &lock->l_remote_handle,
> -				    &reply->lock_handle,
> -				    &lock->l_exp_hash);
> -	} else {
> -		lock->l_remote_handle = reply->lock_handle;
> -	}
> +	lock->l_remote_handle = reply->lock_handle;
>  
>  	LDLM_DEBUG(lock, "replayed lock:");
>  	ptlrpc_import_recovery_state_machine(req->rq_import);
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index 63ccbabb4c5a..86e22472719a 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -721,8 +721,6 @@ struct obd_export *class_new_export(struct obd_device *obd,
>  		return ERR_PTR(-ENOMEM);
>  
>  	export->exp_conn_cnt = 0;
> -	export->exp_lock_hash = NULL;
> -	export->exp_flock_hash = NULL;
>  	atomic_set(&export->exp_refcount, 2);
>  	atomic_set(&export->exp_rpc_count, 0);
>  	atomic_set(&export->exp_cb_count, 0);
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 04/17] staging: lustre: remove unused hash tables.
@ 2018-03-30 18:57     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:57 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> exp_lock_hash and exp_flock_hash are unused in
> the client, so remove all references.
> 
> Also remove unused hashtable size definitions.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/lustre_dlm.h |   10 -------
>  .../staging/lustre/lustre/include/lustre_export.h  |    7 -----
>  .../staging/lustre/lustre/include/obd_support.h    |   18 -------------
>  drivers/staging/lustre/lustre/ldlm/ldlm_flock.c    |   11 +-------
>  drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   14 ----------
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   27 +-------------------
>  drivers/staging/lustre/lustre/obdclass/genops.c    |    2 -
>  7 files changed, 3 insertions(+), 86 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> index 7407acf60cf8..5a355fbab401 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> @@ -629,16 +629,6 @@ struct ldlm_lock {
>  	 * Tree node for ldlm_extent.
>  	 */
>  	struct ldlm_interval	*l_tree_node;
> -	/**
> -	 * Per export hash of locks.
> -	 * Protected by per-bucket exp->exp_lock_hash locks.
> -	 */
> -	struct hlist_node	l_exp_hash;
> -	/**
> -	 * Per export hash of flock locks.
> -	 * Protected by per-bucket exp->exp_flock_hash locks.
> -	 */
> -	struct hlist_node	l_exp_flock_hash;
>  	/**
>  	 * Requested mode.
>  	 * Protected by lr_lock.
> diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h
> index 40cd168ed2ea..19ce13bc8ee6 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_export.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_export.h
> @@ -102,13 +102,6 @@ struct obd_export {
>  	struct ptlrpc_connection *exp_connection;
>  	/** Connection count value from last successful reconnect rpc */
>  	__u32		     exp_conn_cnt;
> -	/** Hash list of all ldlm locks granted on this export */
> -	struct cfs_hash	       *exp_lock_hash;
> -	/**
> -	 * Hash list for Posix lock deadlock detection, added with
> -	 * ldlm_lock::l_exp_flock_hash.
> -	 */
> -	struct cfs_hash	       *exp_flock_hash;
>  	struct list_head		exp_outstanding_replies;
>  	struct list_head		exp_uncommitted_replies;
>  	spinlock_t		  exp_uncommitted_replies_lock;
> diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
> index 8595091b8b86..eb2d6cb6b40b 100644
> --- a/drivers/staging/lustre/lustre/include/obd_support.h
> +++ b/drivers/staging/lustre/lustre/include/obd_support.h
> @@ -67,27 +67,9 @@ extern char obd_jobid_var[];
>  #define HASH_UUID_BKT_BITS 5
>  #define HASH_UUID_CUR_BITS 7
>  #define HASH_UUID_MAX_BITS 12
> -#define HASH_NID_BKT_BITS 5
> -#define HASH_NID_CUR_BITS 7
> -#define HASH_NID_MAX_BITS 12
> -#define HASH_NID_STATS_BKT_BITS 5
> -#define HASH_NID_STATS_CUR_BITS 7
> -#define HASH_NID_STATS_MAX_BITS 12
> -#define HASH_LQE_BKT_BITS 5
> -#define HASH_LQE_CUR_BITS 7
> -#define HASH_LQE_MAX_BITS 12
>  #define HASH_CONN_BKT_BITS 5
>  #define HASH_CONN_CUR_BITS 5
>  #define HASH_CONN_MAX_BITS 15
> -#define HASH_EXP_LOCK_BKT_BITS  5
> -#define HASH_EXP_LOCK_CUR_BITS  7
> -#define HASH_EXP_LOCK_MAX_BITS  16
> -#define HASH_CL_ENV_BKT_BITS    5
> -#define HASH_CL_ENV_BITS	10
> -#define HASH_JOB_STATS_BKT_BITS 5
> -#define HASH_JOB_STATS_CUR_BITS 7
> -#define HASH_JOB_STATS_MAX_BITS 12
> -
>  /* Timeout definitions */
>  #define OBD_TIMEOUT_DEFAULT	     100
>  /* Time to wait for all clients to reconnect during recovery (hard limit) */
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> index 411b540b96d9..94f3b1e49896 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
> @@ -83,9 +83,6 @@ ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode)
>  	LDLM_DEBUG(lock, "%s(mode: %d)",
>  		   __func__, mode);
>  
> -	/* Safe to not lock here, since it should be empty anyway */
> -	LASSERT(hlist_unhashed(&lock->l_exp_flock_hash));
> -
>  	list_del_init(&lock->l_res_link);
>  
>  	/* client side - set a flag to prevent sending a CANCEL */
> @@ -263,15 +260,9 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req)
>  		lock->l_policy_data.l_flock.start =
>  			new->l_policy_data.l_flock.end + 1;
>  		new2->l_conn_export = lock->l_conn_export;
> -		if (lock->l_export) {
> +		if (lock->l_export)
>  			new2->l_export = class_export_lock_get(lock->l_export,
>  							       new2);
> -			if (new2->l_export->exp_lock_hash &&
> -			    hlist_unhashed(&new2->l_exp_hash))
> -				cfs_hash_add(new2->l_export->exp_lock_hash,
> -					     &new2->l_remote_handle,
> -					     &new2->l_exp_hash);
> -		}
>  		ldlm_lock_addref_internal_nolock(new2,
>  						 lock->l_granted_mode);
>  
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> index 95bea351d21d..b8fd778d9832 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> @@ -318,18 +318,6 @@ static int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
>  	}
>  	ldlm_set_destroyed(lock);
>  
> -	if (lock->l_export && lock->l_export->exp_lock_hash) {
> -		/* NB: it's safe to call cfs_hash_del() even lock isn't
> -		 * in exp_lock_hash.
> -		 */
> -		/* In the function below, .hs_keycmp resolves to
> -		 * ldlm_export_lock_keycmp()
> -		 */
> -		/* coverity[overrun-buffer-val] */
> -		cfs_hash_del(lock->l_export->exp_lock_hash,
> -			     &lock->l_remote_handle, &lock->l_exp_hash);
> -	}
> -
>  	ldlm_lock_remove_from_lru(lock);
>  	class_handle_unhash(&lock->l_handle);
>  
> @@ -419,8 +407,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource)
>  	lock->l_blocking_lock = NULL;
>  	INIT_LIST_HEAD(&lock->l_sl_mode);
>  	INIT_LIST_HEAD(&lock->l_sl_policy);
> -	INIT_HLIST_NODE(&lock->l_exp_hash);
> -	INIT_HLIST_NODE(&lock->l_exp_flock_hash);
>  
>  	lprocfs_counter_incr(ldlm_res_to_ns(resource)->ns_stats,
>  			     LDLM_NSS_LOCKS);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index be43958e4090..8e79f5e073ff 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -405,19 +405,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
>  	cleanup_phase = 0;
>  
>  	lock_res_and_lock(lock);
> -	/* Key change rehash lock in per-export hash with new key */
> -	if (exp->exp_lock_hash) {
> -		/* In the function below, .hs_keycmp resolves to
> -		 * ldlm_export_lock_keycmp()
> -		 */
> -		/* coverity[overrun-buffer-val] */
> -		cfs_hash_rehash_key(exp->exp_lock_hash,
> -				    &lock->l_remote_handle,
> -				    &reply->lock_handle,
> -				    &lock->l_exp_hash);
> -	} else {
> -		lock->l_remote_handle = reply->lock_handle;
> -	}
> +	lock->l_remote_handle = reply->lock_handle;
>  
>  	*flags = ldlm_flags_from_wire(reply->lock_flags);
>  	lock->l_flags |= ldlm_flags_from_wire(reply->lock_flags &
> @@ -1884,18 +1872,7 @@ static int replay_lock_interpret(const struct lu_env *env,
>  
>  	/* Key change rehash lock in per-export hash with new key */
>  	exp = req->rq_export;
> -	if (exp && exp->exp_lock_hash) {
> -		/* In the function below, .hs_keycmp resolves to
> -		 * ldlm_export_lock_keycmp()
> -		 */
> -		/* coverity[overrun-buffer-val] */
> -		cfs_hash_rehash_key(exp->exp_lock_hash,
> -				    &lock->l_remote_handle,
> -				    &reply->lock_handle,
> -				    &lock->l_exp_hash);
> -	} else {
> -		lock->l_remote_handle = reply->lock_handle;
> -	}
> +	lock->l_remote_handle = reply->lock_handle;
>  
>  	LDLM_DEBUG(lock, "replayed lock:");
>  	ptlrpc_import_recovery_state_machine(req->rq_import);
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index 63ccbabb4c5a..86e22472719a 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -721,8 +721,6 @@ struct obd_export *class_new_export(struct obd_device *obd,
>  		return ERR_PTR(-ENOMEM);
>  
>  	export->exp_conn_cnt = 0;
> -	export->exp_lock_hash = NULL;
> -	export->exp_flock_hash = NULL;
>  	atomic_set(&export->exp_refcount, 2);
>  	atomic_set(&export->exp_rpc_count, 0);
>  	atomic_set(&export->exp_cb_count, 0);
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 05/17] staging: lustre: remove unneeded include.
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 18:57     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:57 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> cfs_hash usage was removed from cl_object.c
> some time ago, so remove the #include as well.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/cl_object.c |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c
> index 7809f6ae1809..f1641645acae 100644
> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
> @@ -53,7 +53,6 @@
>  #include <obd_support.h>
>  #include <lustre_fid.h>
>  #include <linux/list.h>
> -#include <linux/libcfs/libcfs_hash.h>	/* for cfs_hash stuff */
>  #include <cl_object.h>
>  #include <lu_object.h>
>  #include "cl_internal.h"
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 05/17] staging: lustre: remove unneeded include.
@ 2018-03-30 18:57     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:57 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> cfs_hash usage was removed from cl_object.c
> some time ago, so remove the #include as well.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/cl_object.c |    1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c
> index 7809f6ae1809..f1641645acae 100644
> --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
> +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
> @@ -53,7 +53,6 @@
>  #include <obd_support.h>
>  #include <lustre_fid.h>
>  #include <linux/list.h>
> -#include <linux/libcfs/libcfs_hash.h>	/* for cfs_hash stuff */
>  #include <cl_object.h>
>  #include <lu_object.h>
>  #include "cl_internal.h"
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 06/17] staging: lustre: tidy up ldlm_resource_putref()
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 18:58     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:58 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> 1/ the return value of ldlm_resource_putref() is never
>   used, so change it to return 'void'.
> 2/ Move all of the code to run on the last putref to
>    __ldlm_resource_putref_final().  This means a lock
>    is taken in one function and dropped in another, but
>    that isn't too uncommon, and will disappear in a future
>    patch.
>    Now that the code it together, it becomes apparent that
>    we are dropping a ref on the namespace *before* the last
>    use.  So keep the ref until after.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/lustre_dlm.h |    2 +-
>  drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   21 +++++++++-----------
>  2 files changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> index 5a355fbab401..d668d86423a4 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> @@ -1190,7 +1190,7 @@ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
>  					struct ldlm_resource *parent,
>  					const struct ldlm_res_id *,
>  					enum ldlm_type type, int create);
> -int ldlm_resource_putref(struct ldlm_resource *res);
> +void ldlm_resource_putref(struct ldlm_resource *res);
>  void ldlm_resource_add_lock(struct ldlm_resource *res,
>  			    struct list_head *head,
>  			    struct ldlm_lock *lock);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> index 4c44603ab6f9..8841a1bb2c0a 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> @@ -1195,6 +1195,7 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
>  					 struct ldlm_resource *res)
>  {
>  	struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
> +	struct ldlm_namespace *ns = nsb->nsb_namespace;
>  
>  	if (!list_empty(&res->lr_granted)) {
>  		ldlm_resource_dump(D_ERROR, res);
> @@ -1206,15 +1207,18 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
>  		LBUG();
>  	}
>  
> -	cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash,
> +	cfs_hash_bd_del_locked(ns->ns_rs_hash,
>  			       bd, &res->lr_hash);
>  	lu_ref_fini(&res->lr_reference);
> +	cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1);
> +	if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
> +		ns->ns_lvbo->lvbo_free(res);
>  	if (cfs_hash_bd_count_get(bd) == 0)
> -		ldlm_namespace_put(nsb->nsb_namespace);
> +		ldlm_namespace_put(ns);
> +	kmem_cache_free(ldlm_resource_slab, res);
>  }
>  
> -/* Returns 1 if the resource was freed, 0 if it remains. */
> -int ldlm_resource_putref(struct ldlm_resource *res)
> +void ldlm_resource_putref(struct ldlm_resource *res)
>  {
>  	struct ldlm_namespace *ns = ldlm_res_to_ns(res);
>  	struct cfs_hash_bd   bd;
> @@ -1224,15 +1228,8 @@ int ldlm_resource_putref(struct ldlm_resource *res)
>  	       res, atomic_read(&res->lr_refcount) - 1);
>  
>  	cfs_hash_bd_get(ns->ns_rs_hash, &res->lr_name, &bd);
> -	if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) {
> +	if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount))
>  		__ldlm_resource_putref_final(&bd, res);
> -		cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
> -		if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
> -			ns->ns_lvbo->lvbo_free(res);
> -		kmem_cache_free(ldlm_resource_slab, res);
> -		return 1;
> -	}
> -	return 0;
>  }
>  EXPORT_SYMBOL(ldlm_resource_putref);
>  
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 06/17] staging: lustre: tidy up ldlm_resource_putref()
@ 2018-03-30 18:58     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:58 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> 1/ the return value of ldlm_resource_putref() is never
>   used, so change it to return 'void'.
> 2/ Move all of the code to run on the last putref to
>    __ldlm_resource_putref_final().  This means a lock
>    is taken in one function and dropped in another, but
>    that isn't too uncommon, and will disappear in a future
>    patch.
>    Now that the code it together, it becomes apparent that
>    we are dropping a ref on the namespace *before* the last
>    use.  So keep the ref until after.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/include/lustre_dlm.h |    2 +-
>  drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   21 +++++++++-----------
>  2 files changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> index 5a355fbab401..d668d86423a4 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
> @@ -1190,7 +1190,7 @@ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
>  					struct ldlm_resource *parent,
>  					const struct ldlm_res_id *,
>  					enum ldlm_type type, int create);
> -int ldlm_resource_putref(struct ldlm_resource *res);
> +void ldlm_resource_putref(struct ldlm_resource *res);
>  void ldlm_resource_add_lock(struct ldlm_resource *res,
>  			    struct list_head *head,
>  			    struct ldlm_lock *lock);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> index 4c44603ab6f9..8841a1bb2c0a 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> @@ -1195,6 +1195,7 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
>  					 struct ldlm_resource *res)
>  {
>  	struct ldlm_ns_bucket *nsb = res->lr_ns_bucket;
> +	struct ldlm_namespace *ns = nsb->nsb_namespace;
>  
>  	if (!list_empty(&res->lr_granted)) {
>  		ldlm_resource_dump(D_ERROR, res);
> @@ -1206,15 +1207,18 @@ static void __ldlm_resource_putref_final(struct cfs_hash_bd *bd,
>  		LBUG();
>  	}
>  
> -	cfs_hash_bd_del_locked(nsb->nsb_namespace->ns_rs_hash,
> +	cfs_hash_bd_del_locked(ns->ns_rs_hash,
>  			       bd, &res->lr_hash);
>  	lu_ref_fini(&res->lr_reference);
> +	cfs_hash_bd_unlock(ns->ns_rs_hash, bd, 1);
> +	if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
> +		ns->ns_lvbo->lvbo_free(res);
>  	if (cfs_hash_bd_count_get(bd) == 0)
> -		ldlm_namespace_put(nsb->nsb_namespace);
> +		ldlm_namespace_put(ns);
> +	kmem_cache_free(ldlm_resource_slab, res);
>  }
>  
> -/* Returns 1 if the resource was freed, 0 if it remains. */
> -int ldlm_resource_putref(struct ldlm_resource *res)
> +void ldlm_resource_putref(struct ldlm_resource *res)
>  {
>  	struct ldlm_namespace *ns = ldlm_res_to_ns(res);
>  	struct cfs_hash_bd   bd;
> @@ -1224,15 +1228,8 @@ int ldlm_resource_putref(struct ldlm_resource *res)
>  	       res, atomic_read(&res->lr_refcount) - 1);
>  
>  	cfs_hash_bd_get(ns->ns_rs_hash, &res->lr_name, &bd);
> -	if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount)) {
> +	if (cfs_hash_bd_dec_and_lock(ns->ns_rs_hash, &bd, &res->lr_refcount))
>  		__ldlm_resource_putref_final(&bd, res);
> -		cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1);
> -		if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free)
> -			ns->ns_lvbo->lvbo_free(res);
> -		kmem_cache_free(ldlm_resource_slab, res);
> -		return 1;
> -	}
> -	return 0;
>  }
>  EXPORT_SYMBOL(ldlm_resource_putref);
>  
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 07/17] staging: lustre: ldlm: free resource when ldlm_lock_create() fails.
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 18:58     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:58 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> ldlm_lock_create() gets a resource, but don't put it on
> all failure paths. It should.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> index b8fd778d9832..614caa4a9b0e 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> @@ -1551,8 +1551,10 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
>  		return ERR_CAST(res);
>  
>  	lock = ldlm_lock_new(res);
> -	if (!lock)
> +	if (!lock) {
> +		ldlm_resource_putref(res);
>  		return ERR_PTR(-ENOMEM);
> +	}
>  
>  	lock->l_req_mode = mode;
>  	lock->l_ast_data = data;
> @@ -1595,6 +1597,8 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
>  	return ERR_PTR(rc);
>  }
>  
> +
> +
>  /**
>   * Enqueue (request) a lock.
>   * On the client this is called from ldlm_cli_enqueue_fini
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 07/17] staging: lustre: ldlm: free resource when ldlm_lock_create() fails.
@ 2018-03-30 18:58     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:58 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> ldlm_lock_create() gets a resource, but don't put it on
> all failure paths. It should.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/ldlm/ldlm_lock.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> index b8fd778d9832..614caa4a9b0e 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> @@ -1551,8 +1551,10 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
>  		return ERR_CAST(res);
>  
>  	lock = ldlm_lock_new(res);
> -	if (!lock)
> +	if (!lock) {
> +		ldlm_resource_putref(res);
>  		return ERR_PTR(-ENOMEM);
> +	}
>  
>  	lock->l_req_mode = mode;
>  	lock->l_ast_data = data;
> @@ -1595,6 +1597,8 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
>  	return ERR_PTR(rc);
>  }
>  
> +
> +
>  /**
>   * Enqueue (request) a lock.
>   * On the client this is called from ldlm_cli_enqueue_fini
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 08/17] staging: lustre: add container_of_safe()
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 18:59     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:59 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> Luster has a container_of0() function which is similar to
> container_of() but passes an IS_ERR_OR_NULL() pointer through
> unchanged.
> This could be generally useful: bcache at last has a similar function.
> 
> Naming is hard, but the precedent set by hlist_entry_safe() suggests
> a _safe suffix might be most consistent.
> 
> So add container_of_safe() to kernel.h, and replace all occurrences of
> container_of0() with one of
>   - list_first_entry, list_next_entry, when that is a better fit,
>   - container_of(), when the pointer is used as a validpointer in
>     surrounding code,
>   - container_of_safe() when there is no obviously better alternative.

It's nice to see this become part of the kernel proper

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/libcfs/libcfs.h   |   11 -----------
>  drivers/staging/lustre/lustre/include/cl_object.h  |   10 +++++-----
>  drivers/staging/lustre/lustre/include/lu_object.h  |    6 +++---
>  drivers/staging/lustre/lustre/llite/llite_nfs.c    |    2 +-
>  drivers/staging/lustre/lustre/llite/vvp_internal.h |    8 ++++----
>  drivers/staging/lustre/lustre/lmv/lmv_internal.h   |    2 +-
>  .../staging/lustre/lustre/lov/lov_cl_internal.h    |   18 +++++++++---------
>  drivers/staging/lustre/lustre/lov/lov_internal.h   |    2 +-
>  drivers/staging/lustre/lustre/obdclass/lu_object.c |    8 ++++----
>  .../staging/lustre/lustre/obdecho/echo_client.c    |    2 +-
>  .../staging/lustre/lustre/osc/osc_cl_internal.h    |   10 +++++-----
>  drivers/staging/lustre/lustre/osc/osc_internal.h   |    2 +-
>  drivers/staging/lustre/lustre/osc/osc_io.c         |    2 +-
>  drivers/staging/lustre/lustre/osc/osc_object.c     |    2 +-
>  include/linux/kernel.h                             |   16 ++++++++++++++++
>  15 files changed, 53 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> index 392793582956..3b751c436b3d 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> @@ -99,17 +99,6 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
>  int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
>  int libcfs_ioctl(unsigned long cmd, void __user *arg);
>  
> -/* container_of depends on "likely" which is defined in libcfs_private.h */
> -static inline void *__container_of(void *ptr, unsigned long shift)
> -{
> -	if (IS_ERR_OR_NULL(ptr))
> -		return ptr;
> -	return (char *)ptr - shift;
> -}
> -
> -#define container_of0(ptr, type, member) \
> -	((type *)__container_of((void *)(ptr), offsetof(type, member)))
> -
>  #define _LIBCFS_H
>  
>  extern struct miscdevice libcfs_dev;
> diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
> index 341a145c3331..6f7b991be809 100644
> --- a/drivers/staging/lustre/lustre/include/cl_object.h
> +++ b/drivers/staging/lustre/lustre/include/cl_object.h
> @@ -1941,7 +1941,7 @@ static inline int lu_device_is_cl(const struct lu_device *d)
>  static inline struct cl_device *lu2cl_dev(const struct lu_device *d)
>  {
>  	LASSERT(!d || IS_ERR(d) || lu_device_is_cl(d));
> -	return container_of0(d, struct cl_device, cd_lu_dev);
> +	return container_of_safe(d, struct cl_device, cd_lu_dev);
>  }
>  
>  static inline struct lu_device *cl2lu_dev(struct cl_device *d)
> @@ -1952,13 +1952,13 @@ static inline struct lu_device *cl2lu_dev(struct cl_device *d)
>  static inline struct cl_object *lu2cl(const struct lu_object *o)
>  {
>  	LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->lo_dev));
> -	return container_of0(o, struct cl_object, co_lu);
> +	return container_of_safe(o, struct cl_object, co_lu);
>  }
>  
>  static inline const struct cl_object_conf *
>  lu2cl_conf(const struct lu_object_conf *conf)
>  {
> -	return container_of0(conf, struct cl_object_conf, coc_lu);
> +	return container_of_safe(conf, struct cl_object_conf, coc_lu);
>  }
>  
>  static inline struct cl_object *cl_object_next(const struct cl_object *obj)
> @@ -1969,12 +1969,12 @@ static inline struct cl_object *cl_object_next(const struct cl_object *obj)
>  static inline struct cl_device *cl_object_device(const struct cl_object *o)
>  {
>  	LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev));
> -	return container_of0(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
> +	return container_of_safe(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
>  }
>  
>  static inline struct cl_object_header *luh2coh(const struct lu_object_header *h)
>  {
> -	return container_of0(h, struct cl_object_header, coh_lu);
> +	return container_of_safe(h, struct cl_object_header, coh_lu);
>  }
>  
>  static inline struct cl_site *cl_object_site(const struct cl_object *obj)
> diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
> index 35c7b582f36d..c3b0ed518819 100644
> --- a/drivers/staging/lustre/lustre/include/lu_object.h
> +++ b/drivers/staging/lustre/lustre/include/lu_object.h
> @@ -745,15 +745,15 @@ struct lu_object *lu_object_find_slice(const struct lu_env *env,
>  static inline struct lu_object *lu_object_top(struct lu_object_header *h)
>  {
>  	LASSERT(!list_empty(&h->loh_layers));
> -	return container_of0(h->loh_layers.next, struct lu_object, lo_linkage);
> +	return list_first_entry(&h->loh_layers, struct lu_object, lo_linkage);
>  }
>  
>  /**
>   * Next sub-object in the layering
>   */
> -static inline struct lu_object *lu_object_next(const struct lu_object *o)
> +static inline const struct lu_object *lu_object_next(const struct lu_object *o)
>  {
> -	return container_of0(o->lo_linkage.next, struct lu_object, lo_linkage);
> +	return list_next_entry(o, lo_linkage);
>  }
>  
>  /**
> diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c
> index a6a1d80c711a..14172688d55f 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c
> @@ -223,7 +223,7 @@ static int ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name,
>  	/* It is hack to access lde_fid for comparison with lgd_fid.
>  	 * So the input 'name' must be part of the 'lu_dirent'.
>  	 */
> -	struct lu_dirent *lde = container_of0(name, struct lu_dirent, lde_name);
> +	struct lu_dirent *lde = container_of((void*)name, struct lu_dirent, lde_name);
>  	struct ll_getname_data *lgd =
>  		container_of(ctx, struct ll_getname_data, ctx);
>  	struct lu_fid fid;
> diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h
> index 02ea5161d635..7d3abb43584a 100644
> --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h
> +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h
> @@ -263,22 +263,22 @@ static inline struct lu_device *vvp2lu_dev(struct vvp_device *vdv)
>  
>  static inline struct vvp_device *lu2vvp_dev(const struct lu_device *d)
>  {
> -	return container_of0(d, struct vvp_device, vdv_cl.cd_lu_dev);
> +	return container_of_safe(d, struct vvp_device, vdv_cl.cd_lu_dev);
>  }
>  
>  static inline struct vvp_device *cl2vvp_dev(const struct cl_device *d)
>  {
> -	return container_of0(d, struct vvp_device, vdv_cl);
> +	return container_of_safe(d, struct vvp_device, vdv_cl);
>  }
>  
>  static inline struct vvp_object *cl2vvp(const struct cl_object *obj)
>  {
> -	return container_of0(obj, struct vvp_object, vob_cl);
> +	return container_of_safe(obj, struct vvp_object, vob_cl);
>  }
>  
>  static inline struct vvp_object *lu2vvp(const struct lu_object *obj)
>  {
> -	return container_of0(obj, struct vvp_object, vob_cl.co_lu);
> +	return container_of_safe(obj, struct vvp_object, vob_cl.co_lu);
>  }
>  
>  static inline struct inode *vvp_object_inode(const struct cl_object *obj)
> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
> index c27c3c32188d..68a99170c424 100644
> --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h
> +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
> @@ -60,7 +60,7 @@ int lmv_revalidate_slaves(struct obd_export *exp,
>  
>  static inline struct obd_device *lmv2obd_dev(struct lmv_obd *lmv)
>  {
> -	return container_of0(lmv, struct obd_device, u.lmv);
> +	return container_of_safe(lmv, struct obd_device, u.lmv);
>  }
>  
>  static inline struct lmv_tgt_desc *
> diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
> index 1185eceaf497..2e9c75ebdda5 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
> +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
> @@ -496,7 +496,7 @@ static inline struct lu_device *lov2lu_dev(struct lov_device *lov)
>  static inline struct lov_device *lu2lov_dev(const struct lu_device *d)
>  {
>  	LINVRNT(d->ld_type == &lov_device_type);
> -	return container_of0(d, struct lov_device, ld_cl.cd_lu_dev);
> +	return container_of(d, struct lov_device, ld_cl.cd_lu_dev);
>  }
>  
>  static inline struct cl_device *lovsub2cl_dev(struct lovsub_device *lovsub)
> @@ -512,13 +512,13 @@ static inline struct lu_device *lovsub2lu_dev(struct lovsub_device *lovsub)
>  static inline struct lovsub_device *lu2lovsub_dev(const struct lu_device *d)
>  {
>  	LINVRNT(d->ld_type == &lovsub_device_type);
> -	return container_of0(d, struct lovsub_device, acid_cl.cd_lu_dev);
> +	return container_of(d, struct lovsub_device, acid_cl.cd_lu_dev);
>  }
>  
>  static inline struct lovsub_device *cl2lovsub_dev(const struct cl_device *d)
>  {
>  	LINVRNT(d->cd_lu_dev.ld_type == &lovsub_device_type);
> -	return container_of0(d, struct lovsub_device, acid_cl);
> +	return container_of(d, struct lovsub_device, acid_cl);
>  }
>  
>  static inline struct lu_object *lov2lu(struct lov_object *lov)
> @@ -534,13 +534,13 @@ static inline struct cl_object *lov2cl(struct lov_object *lov)
>  static inline struct lov_object *lu2lov(const struct lu_object *obj)
>  {
>  	LINVRNT(lov_is_object(obj));
> -	return container_of0(obj, struct lov_object, lo_cl.co_lu);
> +	return container_of(obj, struct lov_object, lo_cl.co_lu);
>  }
>  
>  static inline struct lov_object *cl2lov(const struct cl_object *obj)
>  {
>  	LINVRNT(lov_is_object(&obj->co_lu));
> -	return container_of0(obj, struct lov_object, lo_cl);
> +	return container_of(obj, struct lov_object, lo_cl);
>  }
>  
>  static inline struct lu_object *lovsub2lu(struct lovsub_object *los)
> @@ -556,13 +556,13 @@ static inline struct cl_object *lovsub2cl(struct lovsub_object *los)
>  static inline struct lovsub_object *cl2lovsub(const struct cl_object *obj)
>  {
>  	LINVRNT(lovsub_is_object(&obj->co_lu));
> -	return container_of0(obj, struct lovsub_object, lso_cl);
> +	return container_of(obj, struct lovsub_object, lso_cl);
>  }
>  
>  static inline struct lovsub_object *lu2lovsub(const struct lu_object *obj)
>  {
>  	LINVRNT(lovsub_is_object(obj));
> -	return container_of0(obj, struct lovsub_object, lso_cl.co_lu);
> +	return container_of(obj, struct lovsub_object, lso_cl.co_lu);
>  }
>  
>  static inline struct lovsub_lock *
> @@ -590,14 +590,14 @@ static inline struct lov_lock *cl2lov_lock(const struct cl_lock_slice *slice)
>  static inline struct lov_page *cl2lov_page(const struct cl_page_slice *slice)
>  {
>  	LINVRNT(lov_is_object(&slice->cpl_obj->co_lu));
> -	return container_of0(slice, struct lov_page, lps_cl);
> +	return container_of(slice, struct lov_page, lps_cl);
>  }
>  
>  static inline struct lovsub_page *
>  cl2lovsub_page(const struct cl_page_slice *slice)
>  {
>  	LINVRNT(lovsub_is_object(&slice->cpl_obj->co_lu));
> -	return container_of0(slice, struct lovsub_page, lsb_cl);
> +	return container_of(slice, struct lovsub_page, lsb_cl);
>  }
>  
>  static inline struct lov_io *cl2lov_io(const struct lu_env *env,
> diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h
> index a56d71c2dda2..27f60dd7ab9a 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_internal.h
> +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
> @@ -277,7 +277,7 @@ static inline bool lov_oinfo_is_dummy(const struct lov_oinfo *loi)
>  
>  static inline struct obd_device *lov2obd(const struct lov_obd *lov)
>  {
> -	return container_of0(lov, struct obd_device, u.lov);
> +	return container_of_safe(lov, struct obd_device, u.lov);
>  }
>  
>  #endif
> diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> index 8ddf23b82a2c..6db5d95d4b36 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> @@ -319,7 +319,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o)
>  		 * lives as long as possible and ->loo_object_free() methods
>  		 * can look at its contents.
>  		 */
> -		o = container_of0(splice.prev, struct lu_object, lo_linkage);
> +		o = container_of(splice.prev, struct lu_object, lo_linkage);
>  		list_del_init(&o->lo_linkage);
>  		o->lo_ops->loo_object_free(env, o);
>  	}
> @@ -404,8 +404,8 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s,
>  		 * races due to the reasons described in lu_object_put().
>  		 */
>  		while (!list_empty(&dispose)) {
> -			h = container_of0(dispose.next,
> -					  struct lu_object_header, loh_lru);
> +			h = container_of(dispose.next,
> +					 struct lu_object_header, loh_lru);
>  			list_del_init(&h->loh_lru);
>  			lu_object_free(env, lu_object_top(h));
>  			lprocfs_counter_incr(s->ls_stats, LU_SS_LRU_PURGED);
> @@ -579,7 +579,7 @@ static struct lu_object *htable_lookup(struct lu_site *s,
>  		return ERR_PTR(-ENOENT);
>  	}
>  
> -	h = container_of0(hnode, struct lu_object_header, loh_hash);
> +	h = container_of(hnode, struct lu_object_header, loh_hash);
>  	if (likely(!lu_object_is_dying(h))) {
>  		cfs_hash_get(s->ls_obj_hash, hnode);
>  		lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
> diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
> index 99a76db51ae0..767067b61109 100644
> --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
> +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
> @@ -99,7 +99,7 @@ static int echo_client_cleanup(struct obd_device *obddev);
>   */
>  static inline struct echo_device *cl2echo_dev(const struct cl_device *dev)
>  {
> -	return container_of0(dev, struct echo_device, ed_cl);
> +	return container_of_safe(dev, struct echo_device, ed_cl);
>  }
>  
>  static inline struct cl_device *echo_dev2cl(struct echo_device *d)
> diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
> index 1449013722f6..dc25dd12d7d5 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
> +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
> @@ -460,7 +460,7 @@ static inline int osc_is_object(const struct lu_object *obj)
>  static inline struct osc_device *lu2osc_dev(const struct lu_device *d)
>  {
>  	LINVRNT(d->ld_type == &osc_device_type);
> -	return container_of0(d, struct osc_device, od_cl.cd_lu_dev);
> +	return container_of(d, struct osc_device, od_cl.cd_lu_dev);
>  }
>  
>  static inline struct obd_export *osc_export(const struct osc_object *obj)
> @@ -476,7 +476,7 @@ static inline struct client_obd *osc_cli(const struct osc_object *obj)
>  static inline struct osc_object *cl2osc(const struct cl_object *obj)
>  {
>  	LINVRNT(osc_is_object(&obj->co_lu));
> -	return container_of0(obj, struct osc_object, oo_cl);
> +	return container_of(obj, struct osc_object, oo_cl);
>  }
>  
>  static inline struct cl_object *osc2cl(const struct osc_object *obj)
> @@ -509,12 +509,12 @@ static inline enum cl_lock_mode osc_ldlm2cl_lock(enum ldlm_mode mode)
>  static inline struct osc_page *cl2osc_page(const struct cl_page_slice *slice)
>  {
>  	LINVRNT(osc_is_object(&slice->cpl_obj->co_lu));
> -	return container_of0(slice, struct osc_page, ops_cl);
> +	return container_of(slice, struct osc_page, ops_cl);
>  }
>  
>  static inline struct osc_page *oap2osc(struct osc_async_page *oap)
>  {
> -	return container_of0(oap, struct osc_page, ops_oap);
> +	return container_of_safe(oap, struct osc_page, ops_oap);
>  }
>  
>  static inline pgoff_t osc_index(struct osc_page *opg)
> @@ -545,7 +545,7 @@ osc_cl_page_osc(struct cl_page *page, struct osc_object *osc)
>  static inline struct osc_lock *cl2osc_lock(const struct cl_lock_slice *slice)
>  {
>  	LINVRNT(osc_is_object(&slice->cls_obj->co_lu));
> -	return container_of0(slice, struct osc_lock, ols_cl);
> +	return container_of(slice, struct osc_lock, ols_cl);
>  }
>  
>  static inline struct osc_lock *osc_lock_at(const struct cl_lock *lock)
> diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h
> index 32db150fd42e..be8c7829b3de 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_internal.h
> +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
> @@ -180,7 +180,7 @@ struct osc_device {
>  
>  static inline struct osc_device *obd2osc_dev(const struct obd_device *d)
>  {
> -	return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
> +	return container_of_safe(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
>  }
>  
>  extern struct lu_kmem_descr osc_caches[];
> diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c
> index 76743faf3e6d..67734a8ed331 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_io.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_io.c
> @@ -55,7 +55,7 @@
>  static struct osc_io *cl2osc_io(const struct lu_env *env,
>  				const struct cl_io_slice *slice)
>  {
> -	struct osc_io *oio = container_of0(slice, struct osc_io, oi_cl);
> +	struct osc_io *oio = container_of_safe(slice, struct osc_io, oi_cl);
>  
>  	LINVRNT(oio == osc_env_io(env));
>  	return oio;
> diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
> index 6baa8e2e00c9..9582d5a642e2 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_object.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_object.c
> @@ -58,7 +58,7 @@ static struct lu_object *osc2lu(struct osc_object *osc)
>  static struct osc_object *lu2osc(const struct lu_object *obj)
>  {
>  	LINVRNT(osc_is_object(obj));
> -	return container_of0(obj, struct osc_object, oo_cl.co_lu);
> +	return container_of(obj, struct osc_object, oo_cl.co_lu);
>  }
>  
>  /*****************************************************************************
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 2da80e079d56..e5e991642d8f 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -941,6 +941,22 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
>  			 "pointer type mismatch in container_of()");	\
>  	((type *)(__mptr - offsetof(type, member))); })
>  
> +/**
> + * container_of_safe - cast a member of a structure out to the containing structure
> + * @ptr:	the pointer to the member.
> + * @type:	the type of the container struct this is embedded in.
> + * @member:	the name of the member within the struct.
> + *
> + * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged.
> + */
> +#define container_of_safe(ptr, type, member) ({				\
> +	void *__mptr = (void *)(ptr);					\
> +	BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&	\
> +			 !__same_type(*(ptr), void),			\
> +			 "pointer type mismatch in container_of()");	\
> +	IS_ERR_OR_NULL(ptr) ? ERR_CAST(ptr) :				\
> +		((type *)(__mptr - offsetof(type, member))); })
> +
>  /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
>  #ifdef CONFIG_FTRACE_MCOUNT_RECORD
>  # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 08/17] staging: lustre: add container_of_safe()
@ 2018-03-30 18:59     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 18:59 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> Luster has a container_of0() function which is similar to
> container_of() but passes an IS_ERR_OR_NULL() pointer through
> unchanged.
> This could be generally useful: bcache at last has a similar function.
> 
> Naming is hard, but the precedent set by hlist_entry_safe() suggests
> a _safe suffix might be most consistent.
> 
> So add container_of_safe() to kernel.h, and replace all occurrences of
> container_of0() with one of
>   - list_first_entry, list_next_entry, when that is a better fit,
>   - container_of(), when the pointer is used as a validpointer in
>     surrounding code,
>   - container_of_safe() when there is no obviously better alternative.

It's nice to see this become part of the kernel proper

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/libcfs/libcfs.h   |   11 -----------
>  drivers/staging/lustre/lustre/include/cl_object.h  |   10 +++++-----
>  drivers/staging/lustre/lustre/include/lu_object.h  |    6 +++---
>  drivers/staging/lustre/lustre/llite/llite_nfs.c    |    2 +-
>  drivers/staging/lustre/lustre/llite/vvp_internal.h |    8 ++++----
>  drivers/staging/lustre/lustre/lmv/lmv_internal.h   |    2 +-
>  .../staging/lustre/lustre/lov/lov_cl_internal.h    |   18 +++++++++---------
>  drivers/staging/lustre/lustre/lov/lov_internal.h   |    2 +-
>  drivers/staging/lustre/lustre/obdclass/lu_object.c |    8 ++++----
>  .../staging/lustre/lustre/obdecho/echo_client.c    |    2 +-
>  .../staging/lustre/lustre/osc/osc_cl_internal.h    |   10 +++++-----
>  drivers/staging/lustre/lustre/osc/osc_internal.h   |    2 +-
>  drivers/staging/lustre/lustre/osc/osc_io.c         |    2 +-
>  drivers/staging/lustre/lustre/osc/osc_object.c     |    2 +-
>  include/linux/kernel.h                             |   16 ++++++++++++++++
>  15 files changed, 53 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> index 392793582956..3b751c436b3d 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> @@ -99,17 +99,6 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
>  int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
>  int libcfs_ioctl(unsigned long cmd, void __user *arg);
>  
> -/* container_of depends on "likely" which is defined in libcfs_private.h */
> -static inline void *__container_of(void *ptr, unsigned long shift)
> -{
> -	if (IS_ERR_OR_NULL(ptr))
> -		return ptr;
> -	return (char *)ptr - shift;
> -}
> -
> -#define container_of0(ptr, type, member) \
> -	((type *)__container_of((void *)(ptr), offsetof(type, member)))
> -
>  #define _LIBCFS_H
>  
>  extern struct miscdevice libcfs_dev;
> diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
> index 341a145c3331..6f7b991be809 100644
> --- a/drivers/staging/lustre/lustre/include/cl_object.h
> +++ b/drivers/staging/lustre/lustre/include/cl_object.h
> @@ -1941,7 +1941,7 @@ static inline int lu_device_is_cl(const struct lu_device *d)
>  static inline struct cl_device *lu2cl_dev(const struct lu_device *d)
>  {
>  	LASSERT(!d || IS_ERR(d) || lu_device_is_cl(d));
> -	return container_of0(d, struct cl_device, cd_lu_dev);
> +	return container_of_safe(d, struct cl_device, cd_lu_dev);
>  }
>  
>  static inline struct lu_device *cl2lu_dev(struct cl_device *d)
> @@ -1952,13 +1952,13 @@ static inline struct lu_device *cl2lu_dev(struct cl_device *d)
>  static inline struct cl_object *lu2cl(const struct lu_object *o)
>  {
>  	LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->lo_dev));
> -	return container_of0(o, struct cl_object, co_lu);
> +	return container_of_safe(o, struct cl_object, co_lu);
>  }
>  
>  static inline const struct cl_object_conf *
>  lu2cl_conf(const struct lu_object_conf *conf)
>  {
> -	return container_of0(conf, struct cl_object_conf, coc_lu);
> +	return container_of_safe(conf, struct cl_object_conf, coc_lu);
>  }
>  
>  static inline struct cl_object *cl_object_next(const struct cl_object *obj)
> @@ -1969,12 +1969,12 @@ static inline struct cl_object *cl_object_next(const struct cl_object *obj)
>  static inline struct cl_device *cl_object_device(const struct cl_object *o)
>  {
>  	LASSERT(!o || IS_ERR(o) || lu_device_is_cl(o->co_lu.lo_dev));
> -	return container_of0(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
> +	return container_of_safe(o->co_lu.lo_dev, struct cl_device, cd_lu_dev);
>  }
>  
>  static inline struct cl_object_header *luh2coh(const struct lu_object_header *h)
>  {
> -	return container_of0(h, struct cl_object_header, coh_lu);
> +	return container_of_safe(h, struct cl_object_header, coh_lu);
>  }
>  
>  static inline struct cl_site *cl_object_site(const struct cl_object *obj)
> diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
> index 35c7b582f36d..c3b0ed518819 100644
> --- a/drivers/staging/lustre/lustre/include/lu_object.h
> +++ b/drivers/staging/lustre/lustre/include/lu_object.h
> @@ -745,15 +745,15 @@ struct lu_object *lu_object_find_slice(const struct lu_env *env,
>  static inline struct lu_object *lu_object_top(struct lu_object_header *h)
>  {
>  	LASSERT(!list_empty(&h->loh_layers));
> -	return container_of0(h->loh_layers.next, struct lu_object, lo_linkage);
> +	return list_first_entry(&h->loh_layers, struct lu_object, lo_linkage);
>  }
>  
>  /**
>   * Next sub-object in the layering
>   */
> -static inline struct lu_object *lu_object_next(const struct lu_object *o)
> +static inline const struct lu_object *lu_object_next(const struct lu_object *o)
>  {
> -	return container_of0(o->lo_linkage.next, struct lu_object, lo_linkage);
> +	return list_next_entry(o, lo_linkage);
>  }
>  
>  /**
> diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c
> index a6a1d80c711a..14172688d55f 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c
> @@ -223,7 +223,7 @@ static int ll_nfs_get_name_filldir(struct dir_context *ctx, const char *name,
>  	/* It is hack to access lde_fid for comparison with lgd_fid.
>  	 * So the input 'name' must be part of the 'lu_dirent'.
>  	 */
> -	struct lu_dirent *lde = container_of0(name, struct lu_dirent, lde_name);
> +	struct lu_dirent *lde = container_of((void*)name, struct lu_dirent, lde_name);
>  	struct ll_getname_data *lgd =
>  		container_of(ctx, struct ll_getname_data, ctx);
>  	struct lu_fid fid;
> diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h
> index 02ea5161d635..7d3abb43584a 100644
> --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h
> +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h
> @@ -263,22 +263,22 @@ static inline struct lu_device *vvp2lu_dev(struct vvp_device *vdv)
>  
>  static inline struct vvp_device *lu2vvp_dev(const struct lu_device *d)
>  {
> -	return container_of0(d, struct vvp_device, vdv_cl.cd_lu_dev);
> +	return container_of_safe(d, struct vvp_device, vdv_cl.cd_lu_dev);
>  }
>  
>  static inline struct vvp_device *cl2vvp_dev(const struct cl_device *d)
>  {
> -	return container_of0(d, struct vvp_device, vdv_cl);
> +	return container_of_safe(d, struct vvp_device, vdv_cl);
>  }
>  
>  static inline struct vvp_object *cl2vvp(const struct cl_object *obj)
>  {
> -	return container_of0(obj, struct vvp_object, vob_cl);
> +	return container_of_safe(obj, struct vvp_object, vob_cl);
>  }
>  
>  static inline struct vvp_object *lu2vvp(const struct lu_object *obj)
>  {
> -	return container_of0(obj, struct vvp_object, vob_cl.co_lu);
> +	return container_of_safe(obj, struct vvp_object, vob_cl.co_lu);
>  }
>  
>  static inline struct inode *vvp_object_inode(const struct cl_object *obj)
> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
> index c27c3c32188d..68a99170c424 100644
> --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h
> +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
> @@ -60,7 +60,7 @@ int lmv_revalidate_slaves(struct obd_export *exp,
>  
>  static inline struct obd_device *lmv2obd_dev(struct lmv_obd *lmv)
>  {
> -	return container_of0(lmv, struct obd_device, u.lmv);
> +	return container_of_safe(lmv, struct obd_device, u.lmv);
>  }
>  
>  static inline struct lmv_tgt_desc *
> diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
> index 1185eceaf497..2e9c75ebdda5 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
> +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h
> @@ -496,7 +496,7 @@ static inline struct lu_device *lov2lu_dev(struct lov_device *lov)
>  static inline struct lov_device *lu2lov_dev(const struct lu_device *d)
>  {
>  	LINVRNT(d->ld_type == &lov_device_type);
> -	return container_of0(d, struct lov_device, ld_cl.cd_lu_dev);
> +	return container_of(d, struct lov_device, ld_cl.cd_lu_dev);
>  }
>  
>  static inline struct cl_device *lovsub2cl_dev(struct lovsub_device *lovsub)
> @@ -512,13 +512,13 @@ static inline struct lu_device *lovsub2lu_dev(struct lovsub_device *lovsub)
>  static inline struct lovsub_device *lu2lovsub_dev(const struct lu_device *d)
>  {
>  	LINVRNT(d->ld_type == &lovsub_device_type);
> -	return container_of0(d, struct lovsub_device, acid_cl.cd_lu_dev);
> +	return container_of(d, struct lovsub_device, acid_cl.cd_lu_dev);
>  }
>  
>  static inline struct lovsub_device *cl2lovsub_dev(const struct cl_device *d)
>  {
>  	LINVRNT(d->cd_lu_dev.ld_type == &lovsub_device_type);
> -	return container_of0(d, struct lovsub_device, acid_cl);
> +	return container_of(d, struct lovsub_device, acid_cl);
>  }
>  
>  static inline struct lu_object *lov2lu(struct lov_object *lov)
> @@ -534,13 +534,13 @@ static inline struct cl_object *lov2cl(struct lov_object *lov)
>  static inline struct lov_object *lu2lov(const struct lu_object *obj)
>  {
>  	LINVRNT(lov_is_object(obj));
> -	return container_of0(obj, struct lov_object, lo_cl.co_lu);
> +	return container_of(obj, struct lov_object, lo_cl.co_lu);
>  }
>  
>  static inline struct lov_object *cl2lov(const struct cl_object *obj)
>  {
>  	LINVRNT(lov_is_object(&obj->co_lu));
> -	return container_of0(obj, struct lov_object, lo_cl);
> +	return container_of(obj, struct lov_object, lo_cl);
>  }
>  
>  static inline struct lu_object *lovsub2lu(struct lovsub_object *los)
> @@ -556,13 +556,13 @@ static inline struct cl_object *lovsub2cl(struct lovsub_object *los)
>  static inline struct lovsub_object *cl2lovsub(const struct cl_object *obj)
>  {
>  	LINVRNT(lovsub_is_object(&obj->co_lu));
> -	return container_of0(obj, struct lovsub_object, lso_cl);
> +	return container_of(obj, struct lovsub_object, lso_cl);
>  }
>  
>  static inline struct lovsub_object *lu2lovsub(const struct lu_object *obj)
>  {
>  	LINVRNT(lovsub_is_object(obj));
> -	return container_of0(obj, struct lovsub_object, lso_cl.co_lu);
> +	return container_of(obj, struct lovsub_object, lso_cl.co_lu);
>  }
>  
>  static inline struct lovsub_lock *
> @@ -590,14 +590,14 @@ static inline struct lov_lock *cl2lov_lock(const struct cl_lock_slice *slice)
>  static inline struct lov_page *cl2lov_page(const struct cl_page_slice *slice)
>  {
>  	LINVRNT(lov_is_object(&slice->cpl_obj->co_lu));
> -	return container_of0(slice, struct lov_page, lps_cl);
> +	return container_of(slice, struct lov_page, lps_cl);
>  }
>  
>  static inline struct lovsub_page *
>  cl2lovsub_page(const struct cl_page_slice *slice)
>  {
>  	LINVRNT(lovsub_is_object(&slice->cpl_obj->co_lu));
> -	return container_of0(slice, struct lovsub_page, lsb_cl);
> +	return container_of(slice, struct lovsub_page, lsb_cl);
>  }
>  
>  static inline struct lov_io *cl2lov_io(const struct lu_env *env,
> diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h
> index a56d71c2dda2..27f60dd7ab9a 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_internal.h
> +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
> @@ -277,7 +277,7 @@ static inline bool lov_oinfo_is_dummy(const struct lov_oinfo *loi)
>  
>  static inline struct obd_device *lov2obd(const struct lov_obd *lov)
>  {
> -	return container_of0(lov, struct obd_device, u.lov);
> +	return container_of_safe(lov, struct obd_device, u.lov);
>  }
>  
>  #endif
> diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> index 8ddf23b82a2c..6db5d95d4b36 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
> @@ -319,7 +319,7 @@ static void lu_object_free(const struct lu_env *env, struct lu_object *o)
>  		 * lives as long as possible and ->loo_object_free() methods
>  		 * can look at its contents.
>  		 */
> -		o = container_of0(splice.prev, struct lu_object, lo_linkage);
> +		o = container_of(splice.prev, struct lu_object, lo_linkage);
>  		list_del_init(&o->lo_linkage);
>  		o->lo_ops->loo_object_free(env, o);
>  	}
> @@ -404,8 +404,8 @@ int lu_site_purge_objects(const struct lu_env *env, struct lu_site *s,
>  		 * races due to the reasons described in lu_object_put().
>  		 */
>  		while (!list_empty(&dispose)) {
> -			h = container_of0(dispose.next,
> -					  struct lu_object_header, loh_lru);
> +			h = container_of(dispose.next,
> +					 struct lu_object_header, loh_lru);
>  			list_del_init(&h->loh_lru);
>  			lu_object_free(env, lu_object_top(h));
>  			lprocfs_counter_incr(s->ls_stats, LU_SS_LRU_PURGED);
> @@ -579,7 +579,7 @@ static struct lu_object *htable_lookup(struct lu_site *s,
>  		return ERR_PTR(-ENOENT);
>  	}
>  
> -	h = container_of0(hnode, struct lu_object_header, loh_hash);
> +	h = container_of(hnode, struct lu_object_header, loh_hash);
>  	if (likely(!lu_object_is_dying(h))) {
>  		cfs_hash_get(s->ls_obj_hash, hnode);
>  		lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_HIT);
> diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
> index 99a76db51ae0..767067b61109 100644
> --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
> +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
> @@ -99,7 +99,7 @@ static int echo_client_cleanup(struct obd_device *obddev);
>   */
>  static inline struct echo_device *cl2echo_dev(const struct cl_device *dev)
>  {
> -	return container_of0(dev, struct echo_device, ed_cl);
> +	return container_of_safe(dev, struct echo_device, ed_cl);
>  }
>  
>  static inline struct cl_device *echo_dev2cl(struct echo_device *d)
> diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
> index 1449013722f6..dc25dd12d7d5 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
> +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h
> @@ -460,7 +460,7 @@ static inline int osc_is_object(const struct lu_object *obj)
>  static inline struct osc_device *lu2osc_dev(const struct lu_device *d)
>  {
>  	LINVRNT(d->ld_type == &osc_device_type);
> -	return container_of0(d, struct osc_device, od_cl.cd_lu_dev);
> +	return container_of(d, struct osc_device, od_cl.cd_lu_dev);
>  }
>  
>  static inline struct obd_export *osc_export(const struct osc_object *obj)
> @@ -476,7 +476,7 @@ static inline struct client_obd *osc_cli(const struct osc_object *obj)
>  static inline struct osc_object *cl2osc(const struct cl_object *obj)
>  {
>  	LINVRNT(osc_is_object(&obj->co_lu));
> -	return container_of0(obj, struct osc_object, oo_cl);
> +	return container_of(obj, struct osc_object, oo_cl);
>  }
>  
>  static inline struct cl_object *osc2cl(const struct osc_object *obj)
> @@ -509,12 +509,12 @@ static inline enum cl_lock_mode osc_ldlm2cl_lock(enum ldlm_mode mode)
>  static inline struct osc_page *cl2osc_page(const struct cl_page_slice *slice)
>  {
>  	LINVRNT(osc_is_object(&slice->cpl_obj->co_lu));
> -	return container_of0(slice, struct osc_page, ops_cl);
> +	return container_of(slice, struct osc_page, ops_cl);
>  }
>  
>  static inline struct osc_page *oap2osc(struct osc_async_page *oap)
>  {
> -	return container_of0(oap, struct osc_page, ops_oap);
> +	return container_of_safe(oap, struct osc_page, ops_oap);
>  }
>  
>  static inline pgoff_t osc_index(struct osc_page *opg)
> @@ -545,7 +545,7 @@ osc_cl_page_osc(struct cl_page *page, struct osc_object *osc)
>  static inline struct osc_lock *cl2osc_lock(const struct cl_lock_slice *slice)
>  {
>  	LINVRNT(osc_is_object(&slice->cls_obj->co_lu));
> -	return container_of0(slice, struct osc_lock, ols_cl);
> +	return container_of(slice, struct osc_lock, ols_cl);
>  }
>  
>  static inline struct osc_lock *osc_lock_at(const struct cl_lock *lock)
> diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h
> index 32db150fd42e..be8c7829b3de 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_internal.h
> +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
> @@ -180,7 +180,7 @@ struct osc_device {
>  
>  static inline struct osc_device *obd2osc_dev(const struct obd_device *d)
>  {
> -	return container_of0(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
> +	return container_of_safe(d->obd_lu_dev, struct osc_device, od_cl.cd_lu_dev);
>  }
>  
>  extern struct lu_kmem_descr osc_caches[];
> diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c
> index 76743faf3e6d..67734a8ed331 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_io.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_io.c
> @@ -55,7 +55,7 @@
>  static struct osc_io *cl2osc_io(const struct lu_env *env,
>  				const struct cl_io_slice *slice)
>  {
> -	struct osc_io *oio = container_of0(slice, struct osc_io, oi_cl);
> +	struct osc_io *oio = container_of_safe(slice, struct osc_io, oi_cl);
>  
>  	LINVRNT(oio == osc_env_io(env));
>  	return oio;
> diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
> index 6baa8e2e00c9..9582d5a642e2 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_object.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_object.c
> @@ -58,7 +58,7 @@ static struct lu_object *osc2lu(struct osc_object *osc)
>  static struct osc_object *lu2osc(const struct lu_object *obj)
>  {
>  	LINVRNT(osc_is_object(obj));
> -	return container_of0(obj, struct osc_object, oo_cl.co_lu);
> +	return container_of(obj, struct osc_object, oo_cl.co_lu);
>  }
>  
>  /*****************************************************************************
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 2da80e079d56..e5e991642d8f 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -941,6 +941,22 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
>  			 "pointer type mismatch in container_of()");	\
>  	((type *)(__mptr - offsetof(type, member))); })
>  
> +/**
> + * container_of_safe - cast a member of a structure out to the containing structure
> + * @ptr:	the pointer to the member.
> + * @type:	the type of the container struct this is embedded in.
> + * @member:	the name of the member within the struct.
> + *
> + * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged.
> + */
> +#define container_of_safe(ptr, type, member) ({				\
> +	void *__mptr = (void *)(ptr);					\
> +	BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&	\
> +			 !__same_type(*(ptr), void),			\
> +			 "pointer type mismatch in container_of()");	\
> +	IS_ERR_OR_NULL(ptr) ? ERR_CAST(ptr) :				\
> +		((type *)(__mptr - offsetof(type, member))); })
> +
>  /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
>  #ifdef CONFIG_FTRACE_MCOUNT_RECORD
>  # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 10/17] staging: lustre: libcfs: discard cfs_time_add/sub
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 19:00     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:00 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> cfs_time_add adds its arguments.
> cfs_time_sub subtracts finds the difference.
> Discard these and use '+' and '-' directly.
> 
> This change highlighted a type error.  The structure field
> cr_queued_time was used to store jiffies, but was declared
> as time_t (meant for seconds).  So the time is changed to
> "unsigned long".

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/libcfs_time.h      |   12 +---------
>  .../lustre/include/linux/libcfs/linux/linux-time.h |    8 +------
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    2 +-
>  .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   23 +++++++-------------
>  drivers/staging/lustre/lnet/lnet/lib-move.c        |    6 ++---
>  drivers/staging/lustre/lnet/lnet/router.c          |    5 ++--
>  drivers/staging/lustre/lnet/lnet/router_proc.c     |    7 +++---
>  drivers/staging/lustre/lnet/selftest/conrpc.c      |    4 ++-
>  drivers/staging/lustre/lnet/selftest/timer.c       |    2 +-
>  drivers/staging/lustre/lustre/include/lustre_net.h |    5 ++--
>  drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    3 +--
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    8 +++----
>  drivers/staging/lustre/lustre/osc/osc_object.c     |    3 +--
>  drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    9 +++-----
>  drivers/staging/lustre/lustre/ptlrpc/service.c     |    2 +-
>  15 files changed, 32 insertions(+), 67 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> index df7a3f13f3b3..7b41a129f041 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> @@ -40,16 +40,6 @@
>   * generic time manipulation functions.
>   */
>  
> -static inline unsigned long cfs_time_add(unsigned long t, long d)
> -{
> -	return (unsigned long)(t + d);
> -}
> -
> -static inline unsigned long cfs_time_sub(unsigned long t1, unsigned long t2)
> -{
> -	return (unsigned long)(t1 - t2);
> -}
> -
>  static inline int cfs_time_after(unsigned long t1, unsigned long t2)
>  {
>  	return time_before(t2, t1);
> @@ -62,7 +52,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
>  
>  static inline unsigned long cfs_time_shift(int seconds)
>  {
> -	return cfs_time_add(jiffies, seconds * HZ);
> +	return jiffies + seconds * HZ;
>  }
>  
>  /*
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index ba115e8c820f..b3a80531bd71 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -65,15 +65,9 @@ static inline long cfs_duration_sec(long d)
>  	return d / msecs_to_jiffies(MSEC_PER_SEC);
>  }
>  
> -static inline u64 cfs_time_add_64(u64 t, u64 d)
> -{
> -	return t + d;
> -}
> -
>  static inline u64 cfs_time_shift_64(int seconds)
>  {
> -	return cfs_time_add_64(get_jiffies_64(),
> -			       seconds * HZ);
> +	return get_jiffies_64() + (u64)seconds * HZ;
>  }
>  
>  static inline int cfs_time_before_64(u64 t1, u64 t2)
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 0efde0009a15..4546618c1c12 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
>  		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
>  		       &conn->ksnc_ipaddr, conn->ksnc_port,
>  		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
> -		       cfs_duration_sec(cfs_time_sub(jiffies, last_rcv)));
> +		       cfs_duration_sec(jiffies - last_rcv));
>  		lnet_finalize(conn->ksnc_peer->ksnp_ni,
>  			      conn->ksnc_cookie, -EIO);
>  		break;
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index f97da4540b51..5b34c7c030ad 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -481,8 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>  		LASSERT(conn->ksnc_tx_scheduled);
>  		list_add_tail(&conn->ksnc_tx_list,
>  			      &ksocknal_data.ksnd_enomem_conns);
> -		if (!cfs_time_aftereq(cfs_time_add(jiffies,
> -						   SOCKNAL_ENOMEM_RETRY),
> +		if (!cfs_time_aftereq(jiffies + SOCKNAL_ENOMEM_RETRY,
>  				   ksocknal_data.ksnd_reaper_waketime))
>  			wake_up(&ksocknal_data.ksnd_reaper_waitq);
>  
> @@ -1777,8 +1776,7 @@ ksocknal_connect(struct ksock_route *route)
>  	int retry_later = 0;
>  	int rc = 0;
>  
> -	deadline = cfs_time_add(jiffies,
> -				*ksocknal_tunables.ksnd_timeout * HZ);
> +	deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  
>  	write_lock_bh(&ksocknal_data.ksnd_global_lock);
>  
> @@ -1877,8 +1875,7 @@ ksocknal_connect(struct ksock_route *route)
>  			 */
>  			route->ksnr_retry_interval =
>  				*ksocknal_tunables.ksnd_min_reconnectms * HZ / 1000;
> -			route->ksnr_timeout = cfs_time_add(jiffies,
> -							   route->ksnr_retry_interval);
> +			route->ksnr_timeout = jiffies + route->ksnr_retry_interval;
>  		}
>  
>  		ksocknal_launch_connection_locked(route);
> @@ -1903,8 +1900,7 @@ ksocknal_connect(struct ksock_route *route)
>  		    (long)*ksocknal_tunables.ksnd_max_reconnectms * HZ / 1000);
>  
>  	LASSERT(route->ksnr_retry_interval);
> -	route->ksnr_timeout = cfs_time_add(jiffies,
> -					   route->ksnr_retry_interval);
> +	route->ksnr_timeout = jiffies + route->ksnr_retry_interval;
>  
>  	if (!list_empty(&peer->ksnp_tx_queue) &&
>  	    !peer->ksnp_accepting &&
> @@ -2302,8 +2298,7 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
>  
>  	if (*ksocknal_tunables.ksnd_keepalive <= 0 ||
>  	    time_before(jiffies,
> -			cfs_time_add(peer->ksnp_last_alive,
> -				     *ksocknal_tunables.ksnd_keepalive * HZ)))
> +			peer->ksnp_last_alive + *ksocknal_tunables.ksnd_keepalive * HZ))
>  		return 0;
>  
>  	if (time_before(jiffies, peer->ksnp_send_keepalive))
> @@ -2531,8 +2526,7 @@ ksocknal_reaper(void *arg)
>  		}
>  
>  		/* careful with the jiffy wrap... */
> -		while ((timeout = cfs_time_sub(deadline,
> -					       jiffies)) <= 0) {
> +		while ((timeout = deadline - jiffies) <= 0) {
>  			const int n = 4;
>  			const int p = 1;
>  			int chunk = ksocknal_data.ksnd_peer_hash_size;
> @@ -2557,7 +2551,7 @@ ksocknal_reaper(void *arg)
>  					     ksocknal_data.ksnd_peer_hash_size;
>  			}
>  
> -			deadline = cfs_time_add(deadline, p * HZ);
> +			deadline = deadline + p * HZ;
>  		}
>  
>  		if (nenomem_conns) {
> @@ -2568,8 +2562,7 @@ ksocknal_reaper(void *arg)
>  			 */
>  			timeout = SOCKNAL_ENOMEM_RETRY;
>  		}
> -		ksocknal_data.ksnd_reaper_waketime =
> -			cfs_time_add(jiffies, timeout);
> +		ksocknal_data.ksnd_reaper_waketime = jiffies + timeout;
>  
>  		set_current_state(TASK_INTERRUPTIBLE);
>  		add_wait_queue(&ksocknal_data.ksnd_reaper_waitq, &wait);
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
> index 289ed876bd81..5574d2148c9d 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-move.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
> @@ -523,8 +523,7 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
>  	    cfs_time_aftereq(lp->lp_timestamp, lp->lp_last_alive))
>  		return 0;
>  
> -	deadline = cfs_time_add(lp->lp_last_alive,
> -				lp->lp_ni->ni_peertimeout * HZ);
> +	deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout * HZ;
>  	alive = cfs_time_after(deadline, now);
>  
>  	/* Update obsolete lp_alive except for routers assumed to be dead
> @@ -561,8 +560,7 @@ lnet_peer_alive_locked(struct lnet_peer *lp)
>  		static const int lnet_queryinterval = 1;
>  
>  		unsigned long next_query =
> -			   cfs_time_add(lp->lp_last_query,
> -					lnet_queryinterval * HZ);
> +			   lp->lp_last_query + lnet_queryinterval * HZ;
>  
>  		if (time_before(now, next_query)) {
>  			if (lp->lp_alive)
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index ac9b392a0afa..4595a7ad4336 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -1010,8 +1010,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
>  	       rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
>  
>  	if (secs && !rtr->lp_ping_notsent &&
> -	    cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp,
> -					     secs * HZ))) {
> +	    cfs_time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
>  		int rc;
>  		struct lnet_process_id id;
>  		struct lnet_handle_md mdh;
> @@ -1753,7 +1752,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
>  		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
>  		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
>  		      libcfs_nid2str(nid), alive ? "up" : "down",
> -		      cfs_duration_sec(cfs_time_sub(when, now)));
> +		      cfs_duration_sec(when - now));
>  		return -EINVAL;
>  	}
>  
> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
> index 315d067540c0..e4172311be68 100644
> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c
> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
> @@ -331,8 +331,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
>  			int alive_cnt = peer->lp_alive_count;
>  			int alive = peer->lp_alive;
>  			int pingsent = !peer->lp_ping_notsent;
> -			int last_ping = cfs_duration_sec(cfs_time_sub(now,
> -						     peer->lp_ping_timestamp));
> +			int last_ping = cfs_duration_sec(now - peer->lp_ping_timestamp);
>  			int down_ni = 0;
>  			struct lnet_route *rtr;
>  
> @@ -364,7 +363,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
>  					      nrefs, nrtrrefs, alive_cnt,
>  					      alive ? "up" : "down", last_ping,
>  					      pingsent,
> -					      cfs_duration_sec(cfs_time_sub(deadline, now)),
> +					      cfs_duration_sec(deadline - now),
>  					      down_ni, libcfs_nid2str(nid));
>  			LASSERT(tmpstr + tmpsiz - s > 0);
>  		}
> @@ -512,7 +511,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
>  				unsigned long now = jiffies;
>  				long delta;
>  
> -				delta = cfs_time_sub(now, peer->lp_last_alive);
> +				delta = now - peer->lp_last_alive;
>  				lastalive = cfs_duration_sec(delta);
>  
>  				/* No need to mess up peers contents with
> diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
> index 68e06e06857d..ea4944b9108b 100644
> --- a/drivers/staging/lustre/lnet/selftest/conrpc.c
> +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
> @@ -500,8 +500,8 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
>  
>  		nd = crpc->crp_node;
>  
> -		dur = (long)cfs_time_sub(crpc->crp_stamp,
> -		      (unsigned long)console_session.ses_id.ses_stamp);
> +		dur = (long)(crpc->crp_stamp -
> +			     (unsigned long)console_session.ses_id.ses_stamp);
>  		jiffies_to_timeval(dur, &tv);
>  
>  		if (copy_to_user(&ent->rpe_peer, &nd->nd_id,
> diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
> index 1b2c5fc81358..1f9d5487e2f5 100644
> --- a/drivers/staging/lustre/lnet/selftest/timer.c
> +++ b/drivers/staging/lustre/lnet/selftest/timer.c
> @@ -157,7 +157,7 @@ stt_check_timers(unsigned long *last)
>  
>  	while (cfs_time_aftereq(this_slot, *last)) {
>  		expired += stt_expire_list(STTIMER_SLOT(this_slot), now);
> -		this_slot = cfs_time_sub(this_slot, STTIMER_SLOTTIME);
> +		this_slot = this_slot - STTIMER_SLOTTIME;
>  	}
>  
>  	*last = now & STTIMER_SLOTTIMEMASK;
> diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
> index f4824d8ec741..d13db55b7242 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_net.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_net.h
> @@ -556,7 +556,7 @@ struct ptlrpc_cli_req {
>  	/** optional time limit for send attempts */
>  	long				 cr_delay_limit;
>  	/** time request was first queued */
> -	time_t				 cr_queued_time;
> +	unsigned long			 cr_queued_time;
>  	/** request sent timeval */
>  	struct timespec64		 cr_sent_tv;
>  	/** time for request really sent out */
> @@ -2253,8 +2253,7 @@ static inline int ptlrpc_req_get_repsize(struct ptlrpc_request *req)
>  static inline int ptlrpc_send_limit_expired(struct ptlrpc_request *req)
>  {
>  	if (req->rq_delay_limit != 0 &&
> -	    time_before(cfs_time_add(req->rq_queued_time,
> -				     req->rq_delay_limit * HZ),
> +	    time_before(req->rq_queued_time + req->rq_delay_limit * HZ,
>  			jiffies)) {
>  		return 1;
>  	}
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> index ab4dd15c8dd4..150e78c9eb68 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> @@ -326,8 +326,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
>  	if (lock->l_granted_mode == LCK_PW &&
>  	    !lock->l_readers && !lock->l_writers &&
>  	    cfs_time_after(jiffies,
> -			   cfs_time_add(lock->l_last_used,
> -					10 * HZ))) {
> +			   lock->l_last_used + 10 * HZ)) {
>  		unlock_res_and_lock(lock);
>  		if (ldlm_bl_to_thread_lock(ns, NULL, lock))
>  			ldlm_handle_bl_callback(ns, NULL, lock);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index 0e1b21c1f06d..6eb42f16040d 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -1176,13 +1176,12 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
>  	 * Despite of the LV, It doesn't make sense to keep the lock which
>  	 * is unused for ns_max_age time.
>  	 */
> -	if (cfs_time_after(jiffies,
> -			   cfs_time_add(lock->l_last_used, ns->ns_max_age)))
> +	if (cfs_time_after(jiffies, lock->l_last_used + ns->ns_max_age))
>  		return LDLM_POLICY_CANCEL_LOCK;
>  
>  	slv = ldlm_pool_get_slv(pl);
>  	lvf = ldlm_pool_get_lvf(pl);
> -	la = cfs_duration_sec(cfs_time_sub(cur, lock->l_last_used));
> +	la = cfs_duration_sec(cur - lock->l_last_used);
>  	lv = lvf * la * unused;
>  
>  	/* Inform pool about current CLV to see it via debugfs. */
> @@ -1233,8 +1232,7 @@ static enum ldlm_policy_res ldlm_cancel_aged_policy(struct ldlm_namespace *ns,
>  						    int count)
>  {
>  	if ((added >= count) &&
> -	    time_before(jiffies,
> -			cfs_time_add(lock->l_last_used, ns->ns_max_age)))
> +	    time_before(jiffies, lock->l_last_used + ns->ns_max_age))
>  		return LDLM_POLICY_KEEP_LOCK;
>  
>  	return LDLM_POLICY_CANCEL_LOCK;
> diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
> index c5dc894a4c1b..154d1721636e 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_object.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_object.c
> @@ -327,8 +327,7 @@ int osc_object_is_contended(struct osc_object *obj)
>  	 * I like copy-paste. the code is copied from
>  	 * ll_file_is_contended.
>  	 */
> -	retry_time = cfs_time_add(obj->oo_contention_time,
> -				  osc_contention_time * HZ);
> +	retry_time = obj->oo_contention_time + osc_contention_time * HZ;
>  	if (cfs_time_after(cur_time, retry_time)) {
>  		osc_object_clear_contended(obj);
>  		return 0;
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> index 57c7db47e249..e836591c5936 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> @@ -141,8 +141,7 @@ static long pinger_check_timeout(unsigned long time)
>  	}
>  	mutex_unlock(&pinger_mutex);
>  
> -	return cfs_time_sub(cfs_time_add(time, timeout * HZ),
> -					 jiffies);
> +	return time + timeout * HZ - jiffies;
>  }
>  
>  static bool ir_up;
> @@ -238,8 +237,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
>  			/* obd_timeout might have changed */
>  			if (imp->imp_pingable && imp->imp_next_ping &&
>  			    cfs_time_after(imp->imp_next_ping,
> -					   cfs_time_add(this_ping,
> -							PING_INTERVAL * HZ)))
> +					   this_ping + PING_INTERVAL * HZ))
>  				ptlrpc_update_next_ping(imp, 0);
>  		}
>  		mutex_unlock(&pinger_mutex);
> @@ -255,8 +253,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
>  		 */
>  		CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
>  		       time_to_next_wake,
> -		       cfs_time_add(this_ping,
> -				    PING_INTERVAL * HZ));
> +		       this_ping + PING_INTERVAL * HZ);
>  	} while (time_to_next_wake <= 0);
>  
>  	queue_delayed_work(pinger_wq, &ping_work,
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
> index fc29efbd9914..e71046db28e5 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
> @@ -1153,7 +1153,7 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
>  		spin_unlock(&svcpt->scp_at_lock);
>  		return;
>  	}
> -	delay = cfs_time_sub(jiffies, svcpt->scp_at_checktime);
> +	delay = jiffies - svcpt->scp_at_checktime;
>  	svcpt->scp_at_check = 0;
>  
>  	if (array->paa_count == 0) {
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 10/17] staging: lustre: libcfs: discard cfs_time_add/sub
@ 2018-03-30 19:00     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:00 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> cfs_time_add adds its arguments.
> cfs_time_sub subtracts finds the difference.
> Discard these and use '+' and '-' directly.
> 
> This change highlighted a type error.  The structure field
> cr_queued_time was used to store jiffies, but was declared
> as time_t (meant for seconds).  So the time is changed to
> "unsigned long".

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/libcfs_time.h      |   12 +---------
>  .../lustre/include/linux/libcfs/linux/linux-time.h |    8 +------
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    2 +-
>  .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   23 +++++++-------------
>  drivers/staging/lustre/lnet/lnet/lib-move.c        |    6 ++---
>  drivers/staging/lustre/lnet/lnet/router.c          |    5 ++--
>  drivers/staging/lustre/lnet/lnet/router_proc.c     |    7 +++---
>  drivers/staging/lustre/lnet/selftest/conrpc.c      |    4 ++-
>  drivers/staging/lustre/lnet/selftest/timer.c       |    2 +-
>  drivers/staging/lustre/lustre/include/lustre_net.h |    5 ++--
>  drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    3 +--
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    8 +++----
>  drivers/staging/lustre/lustre/osc/osc_object.c     |    3 +--
>  drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    9 +++-----
>  drivers/staging/lustre/lustre/ptlrpc/service.c     |    2 +-
>  15 files changed, 32 insertions(+), 67 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> index df7a3f13f3b3..7b41a129f041 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> @@ -40,16 +40,6 @@
>   * generic time manipulation functions.
>   */
>  
> -static inline unsigned long cfs_time_add(unsigned long t, long d)
> -{
> -	return (unsigned long)(t + d);
> -}
> -
> -static inline unsigned long cfs_time_sub(unsigned long t1, unsigned long t2)
> -{
> -	return (unsigned long)(t1 - t2);
> -}
> -
>  static inline int cfs_time_after(unsigned long t1, unsigned long t2)
>  {
>  	return time_before(t2, t1);
> @@ -62,7 +52,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
>  
>  static inline unsigned long cfs_time_shift(int seconds)
>  {
> -	return cfs_time_add(jiffies, seconds * HZ);
> +	return jiffies + seconds * HZ;
>  }
>  
>  /*
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index ba115e8c820f..b3a80531bd71 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -65,15 +65,9 @@ static inline long cfs_duration_sec(long d)
>  	return d / msecs_to_jiffies(MSEC_PER_SEC);
>  }
>  
> -static inline u64 cfs_time_add_64(u64 t, u64 d)
> -{
> -	return t + d;
> -}
> -
>  static inline u64 cfs_time_shift_64(int seconds)
>  {
> -	return cfs_time_add_64(get_jiffies_64(),
> -			       seconds * HZ);
> +	return get_jiffies_64() + (u64)seconds * HZ;
>  }
>  
>  static inline int cfs_time_before_64(u64 t1, u64 t2)
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 0efde0009a15..4546618c1c12 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
>  		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
>  		       &conn->ksnc_ipaddr, conn->ksnc_port,
>  		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
> -		       cfs_duration_sec(cfs_time_sub(jiffies, last_rcv)));
> +		       cfs_duration_sec(jiffies - last_rcv));
>  		lnet_finalize(conn->ksnc_peer->ksnp_ni,
>  			      conn->ksnc_cookie, -EIO);
>  		break;
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index f97da4540b51..5b34c7c030ad 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -481,8 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>  		LASSERT(conn->ksnc_tx_scheduled);
>  		list_add_tail(&conn->ksnc_tx_list,
>  			      &ksocknal_data.ksnd_enomem_conns);
> -		if (!cfs_time_aftereq(cfs_time_add(jiffies,
> -						   SOCKNAL_ENOMEM_RETRY),
> +		if (!cfs_time_aftereq(jiffies + SOCKNAL_ENOMEM_RETRY,
>  				   ksocknal_data.ksnd_reaper_waketime))
>  			wake_up(&ksocknal_data.ksnd_reaper_waitq);
>  
> @@ -1777,8 +1776,7 @@ ksocknal_connect(struct ksock_route *route)
>  	int retry_later = 0;
>  	int rc = 0;
>  
> -	deadline = cfs_time_add(jiffies,
> -				*ksocknal_tunables.ksnd_timeout * HZ);
> +	deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  
>  	write_lock_bh(&ksocknal_data.ksnd_global_lock);
>  
> @@ -1877,8 +1875,7 @@ ksocknal_connect(struct ksock_route *route)
>  			 */
>  			route->ksnr_retry_interval =
>  				*ksocknal_tunables.ksnd_min_reconnectms * HZ / 1000;
> -			route->ksnr_timeout = cfs_time_add(jiffies,
> -							   route->ksnr_retry_interval);
> +			route->ksnr_timeout = jiffies + route->ksnr_retry_interval;
>  		}
>  
>  		ksocknal_launch_connection_locked(route);
> @@ -1903,8 +1900,7 @@ ksocknal_connect(struct ksock_route *route)
>  		    (long)*ksocknal_tunables.ksnd_max_reconnectms * HZ / 1000);
>  
>  	LASSERT(route->ksnr_retry_interval);
> -	route->ksnr_timeout = cfs_time_add(jiffies,
> -					   route->ksnr_retry_interval);
> +	route->ksnr_timeout = jiffies + route->ksnr_retry_interval;
>  
>  	if (!list_empty(&peer->ksnp_tx_queue) &&
>  	    !peer->ksnp_accepting &&
> @@ -2302,8 +2298,7 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
>  
>  	if (*ksocknal_tunables.ksnd_keepalive <= 0 ||
>  	    time_before(jiffies,
> -			cfs_time_add(peer->ksnp_last_alive,
> -				     *ksocknal_tunables.ksnd_keepalive * HZ)))
> +			peer->ksnp_last_alive + *ksocknal_tunables.ksnd_keepalive * HZ))
>  		return 0;
>  
>  	if (time_before(jiffies, peer->ksnp_send_keepalive))
> @@ -2531,8 +2526,7 @@ ksocknal_reaper(void *arg)
>  		}
>  
>  		/* careful with the jiffy wrap... */
> -		while ((timeout = cfs_time_sub(deadline,
> -					       jiffies)) <= 0) {
> +		while ((timeout = deadline - jiffies) <= 0) {
>  			const int n = 4;
>  			const int p = 1;
>  			int chunk = ksocknal_data.ksnd_peer_hash_size;
> @@ -2557,7 +2551,7 @@ ksocknal_reaper(void *arg)
>  					     ksocknal_data.ksnd_peer_hash_size;
>  			}
>  
> -			deadline = cfs_time_add(deadline, p * HZ);
> +			deadline = deadline + p * HZ;
>  		}
>  
>  		if (nenomem_conns) {
> @@ -2568,8 +2562,7 @@ ksocknal_reaper(void *arg)
>  			 */
>  			timeout = SOCKNAL_ENOMEM_RETRY;
>  		}
> -		ksocknal_data.ksnd_reaper_waketime =
> -			cfs_time_add(jiffies, timeout);
> +		ksocknal_data.ksnd_reaper_waketime = jiffies + timeout;
>  
>  		set_current_state(TASK_INTERRUPTIBLE);
>  		add_wait_queue(&ksocknal_data.ksnd_reaper_waitq, &wait);
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
> index 289ed876bd81..5574d2148c9d 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-move.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
> @@ -523,8 +523,7 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
>  	    cfs_time_aftereq(lp->lp_timestamp, lp->lp_last_alive))
>  		return 0;
>  
> -	deadline = cfs_time_add(lp->lp_last_alive,
> -				lp->lp_ni->ni_peertimeout * HZ);
> +	deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout * HZ;
>  	alive = cfs_time_after(deadline, now);
>  
>  	/* Update obsolete lp_alive except for routers assumed to be dead
> @@ -561,8 +560,7 @@ lnet_peer_alive_locked(struct lnet_peer *lp)
>  		static const int lnet_queryinterval = 1;
>  
>  		unsigned long next_query =
> -			   cfs_time_add(lp->lp_last_query,
> -					lnet_queryinterval * HZ);
> +			   lp->lp_last_query + lnet_queryinterval * HZ;
>  
>  		if (time_before(now, next_query)) {
>  			if (lp->lp_alive)
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index ac9b392a0afa..4595a7ad4336 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -1010,8 +1010,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
>  	       rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
>  
>  	if (secs && !rtr->lp_ping_notsent &&
> -	    cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp,
> -					     secs * HZ))) {
> +	    cfs_time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
>  		int rc;
>  		struct lnet_process_id id;
>  		struct lnet_handle_md mdh;
> @@ -1753,7 +1752,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
>  		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
>  		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
>  		      libcfs_nid2str(nid), alive ? "up" : "down",
> -		      cfs_duration_sec(cfs_time_sub(when, now)));
> +		      cfs_duration_sec(when - now));
>  		return -EINVAL;
>  	}
>  
> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
> index 315d067540c0..e4172311be68 100644
> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c
> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
> @@ -331,8 +331,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
>  			int alive_cnt = peer->lp_alive_count;
>  			int alive = peer->lp_alive;
>  			int pingsent = !peer->lp_ping_notsent;
> -			int last_ping = cfs_duration_sec(cfs_time_sub(now,
> -						     peer->lp_ping_timestamp));
> +			int last_ping = cfs_duration_sec(now - peer->lp_ping_timestamp);
>  			int down_ni = 0;
>  			struct lnet_route *rtr;
>  
> @@ -364,7 +363,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
>  					      nrefs, nrtrrefs, alive_cnt,
>  					      alive ? "up" : "down", last_ping,
>  					      pingsent,
> -					      cfs_duration_sec(cfs_time_sub(deadline, now)),
> +					      cfs_duration_sec(deadline - now),
>  					      down_ni, libcfs_nid2str(nid));
>  			LASSERT(tmpstr + tmpsiz - s > 0);
>  		}
> @@ -512,7 +511,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
>  				unsigned long now = jiffies;
>  				long delta;
>  
> -				delta = cfs_time_sub(now, peer->lp_last_alive);
> +				delta = now - peer->lp_last_alive;
>  				lastalive = cfs_duration_sec(delta);
>  
>  				/* No need to mess up peers contents with
> diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
> index 68e06e06857d..ea4944b9108b 100644
> --- a/drivers/staging/lustre/lnet/selftest/conrpc.c
> +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
> @@ -500,8 +500,8 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
>  
>  		nd = crpc->crp_node;
>  
> -		dur = (long)cfs_time_sub(crpc->crp_stamp,
> -		      (unsigned long)console_session.ses_id.ses_stamp);
> +		dur = (long)(crpc->crp_stamp -
> +			     (unsigned long)console_session.ses_id.ses_stamp);
>  		jiffies_to_timeval(dur, &tv);
>  
>  		if (copy_to_user(&ent->rpe_peer, &nd->nd_id,
> diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
> index 1b2c5fc81358..1f9d5487e2f5 100644
> --- a/drivers/staging/lustre/lnet/selftest/timer.c
> +++ b/drivers/staging/lustre/lnet/selftest/timer.c
> @@ -157,7 +157,7 @@ stt_check_timers(unsigned long *last)
>  
>  	while (cfs_time_aftereq(this_slot, *last)) {
>  		expired += stt_expire_list(STTIMER_SLOT(this_slot), now);
> -		this_slot = cfs_time_sub(this_slot, STTIMER_SLOTTIME);
> +		this_slot = this_slot - STTIMER_SLOTTIME;
>  	}
>  
>  	*last = now & STTIMER_SLOTTIMEMASK;
> diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
> index f4824d8ec741..d13db55b7242 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_net.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_net.h
> @@ -556,7 +556,7 @@ struct ptlrpc_cli_req {
>  	/** optional time limit for send attempts */
>  	long				 cr_delay_limit;
>  	/** time request was first queued */
> -	time_t				 cr_queued_time;
> +	unsigned long			 cr_queued_time;
>  	/** request sent timeval */
>  	struct timespec64		 cr_sent_tv;
>  	/** time for request really sent out */
> @@ -2253,8 +2253,7 @@ static inline int ptlrpc_req_get_repsize(struct ptlrpc_request *req)
>  static inline int ptlrpc_send_limit_expired(struct ptlrpc_request *req)
>  {
>  	if (req->rq_delay_limit != 0 &&
> -	    time_before(cfs_time_add(req->rq_queued_time,
> -				     req->rq_delay_limit * HZ),
> +	    time_before(req->rq_queued_time + req->rq_delay_limit * HZ,
>  			jiffies)) {
>  		return 1;
>  	}
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> index ab4dd15c8dd4..150e78c9eb68 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> @@ -326,8 +326,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
>  	if (lock->l_granted_mode == LCK_PW &&
>  	    !lock->l_readers && !lock->l_writers &&
>  	    cfs_time_after(jiffies,
> -			   cfs_time_add(lock->l_last_used,
> -					10 * HZ))) {
> +			   lock->l_last_used + 10 * HZ)) {
>  		unlock_res_and_lock(lock);
>  		if (ldlm_bl_to_thread_lock(ns, NULL, lock))
>  			ldlm_handle_bl_callback(ns, NULL, lock);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index 0e1b21c1f06d..6eb42f16040d 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -1176,13 +1176,12 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
>  	 * Despite of the LV, It doesn't make sense to keep the lock which
>  	 * is unused for ns_max_age time.
>  	 */
> -	if (cfs_time_after(jiffies,
> -			   cfs_time_add(lock->l_last_used, ns->ns_max_age)))
> +	if (cfs_time_after(jiffies, lock->l_last_used + ns->ns_max_age))
>  		return LDLM_POLICY_CANCEL_LOCK;
>  
>  	slv = ldlm_pool_get_slv(pl);
>  	lvf = ldlm_pool_get_lvf(pl);
> -	la = cfs_duration_sec(cfs_time_sub(cur, lock->l_last_used));
> +	la = cfs_duration_sec(cur - lock->l_last_used);
>  	lv = lvf * la * unused;
>  
>  	/* Inform pool about current CLV to see it via debugfs. */
> @@ -1233,8 +1232,7 @@ static enum ldlm_policy_res ldlm_cancel_aged_policy(struct ldlm_namespace *ns,
>  						    int count)
>  {
>  	if ((added >= count) &&
> -	    time_before(jiffies,
> -			cfs_time_add(lock->l_last_used, ns->ns_max_age)))
> +	    time_before(jiffies, lock->l_last_used + ns->ns_max_age))
>  		return LDLM_POLICY_KEEP_LOCK;
>  
>  	return LDLM_POLICY_CANCEL_LOCK;
> diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
> index c5dc894a4c1b..154d1721636e 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_object.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_object.c
> @@ -327,8 +327,7 @@ int osc_object_is_contended(struct osc_object *obj)
>  	 * I like copy-paste. the code is copied from
>  	 * ll_file_is_contended.
>  	 */
> -	retry_time = cfs_time_add(obj->oo_contention_time,
> -				  osc_contention_time * HZ);
> +	retry_time = obj->oo_contention_time + osc_contention_time * HZ;
>  	if (cfs_time_after(cur_time, retry_time)) {
>  		osc_object_clear_contended(obj);
>  		return 0;
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> index 57c7db47e249..e836591c5936 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> @@ -141,8 +141,7 @@ static long pinger_check_timeout(unsigned long time)
>  	}
>  	mutex_unlock(&pinger_mutex);
>  
> -	return cfs_time_sub(cfs_time_add(time, timeout * HZ),
> -					 jiffies);
> +	return time + timeout * HZ - jiffies;
>  }
>  
>  static bool ir_up;
> @@ -238,8 +237,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
>  			/* obd_timeout might have changed */
>  			if (imp->imp_pingable && imp->imp_next_ping &&
>  			    cfs_time_after(imp->imp_next_ping,
> -					   cfs_time_add(this_ping,
> -							PING_INTERVAL * HZ)))
> +					   this_ping + PING_INTERVAL * HZ))
>  				ptlrpc_update_next_ping(imp, 0);
>  		}
>  		mutex_unlock(&pinger_mutex);
> @@ -255,8 +253,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
>  		 */
>  		CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
>  		       time_to_next_wake,
> -		       cfs_time_add(this_ping,
> -				    PING_INTERVAL * HZ));
> +		       this_ping + PING_INTERVAL * HZ);
>  	} while (time_to_next_wake <= 0);
>  
>  	queue_delayed_work(pinger_wq, &ping_work,
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
> index fc29efbd9914..e71046db28e5 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
> @@ -1153,7 +1153,7 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
>  		spin_unlock(&svcpt->scp_at_lock);
>  		return;
>  	}
> -	delay = cfs_time_sub(jiffies, svcpt->scp_at_checktime);
> +	delay = jiffies - svcpt->scp_at_checktime;
>  	svcpt->scp_at_check = 0;
>  
>  	if (array->paa_count == 0) {
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 09/17] staging: lustre: cfs_time_current() -> jiffies.
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 19:00     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:00 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> Discard cfs_time_current() and cfs_time_current64()
> and use jiffies and get_jiffies_64() like the rest of the kernel.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/libcfs_time.h      |    2 -
>  .../lustre/include/linux/libcfs/linux/linux-time.h |    9 ----
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   14 +++---
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    8 ++--
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    9 ++--
>  .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   44 ++++++++++----------
>  drivers/staging/lustre/lnet/libcfs/tracefile.c     |    6 +--
>  drivers/staging/lustre/lnet/lnet/lib-move.c        |    4 +-
>  drivers/staging/lustre/lnet/lnet/net_fault.c       |    6 +--
>  drivers/staging/lustre/lnet/lnet/peer.c            |    2 -
>  drivers/staging/lustre/lnet/lnet/router.c          |    6 +--
>  drivers/staging/lustre/lnet/lnet/router_proc.c     |    4 +-
>  drivers/staging/lustre/lnet/selftest/conrpc.c      |    6 +--
>  drivers/staging/lustre/lnet/selftest/console.c     |    4 +-
>  drivers/staging/lustre/lnet/selftest/framework.c   |    2 -
>  drivers/staging/lustre/lustre/include/lustre_net.h |    2 -
>  drivers/staging/lustre/lustre/include/obd_class.h  |    6 +--
>  drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |    2 -
>  drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    2 -
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   10 ++---
>  drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 -
>  .../staging/lustre/lustre/llite/llite_internal.h   |    2 -
>  drivers/staging/lustre/lustre/llite/statahead.c    |    2 -
>  drivers/staging/lustre/lustre/lov/lov_request.c    |    4 +-
>  drivers/staging/lustre/lustre/osc/osc_cache.c      |    2 -
>  drivers/staging/lustre/lustre/osc/osc_object.c     |    4 +-
>  drivers/staging/lustre/lustre/osc/osc_page.c       |    4 +-
>  drivers/staging/lustre/lustre/osc/osc_request.c    |    2 -
>  drivers/staging/lustre/lustre/ptlrpc/client.c      |    4 +-
>  drivers/staging/lustre/lustre/ptlrpc/import.c      |    2 -
>  drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    4 +-
>  drivers/staging/lustre/lustre/ptlrpc/service.c     |    4 +-
>  32 files changed, 88 insertions(+), 96 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> index c4f25be78268..df7a3f13f3b3 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> @@ -62,7 +62,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
>  
>  static inline unsigned long cfs_time_shift(int seconds)
>  {
> -	return cfs_time_add(cfs_time_current(), seconds * HZ);
> +	return cfs_time_add(jiffies, seconds * HZ);
>  }
>  
>  /*
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index 805cb326af86..ba115e8c820f 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -60,18 +60,11 @@
>   * Generic kernel stuff
>   */
>  
> -static inline unsigned long cfs_time_current(void)
> -{
> -	return jiffies;
> -}
> -
>  static inline long cfs_duration_sec(long d)
>  {
>  	return d / msecs_to_jiffies(MSEC_PER_SEC);
>  }
>  
> -#define cfs_time_current_64 get_jiffies_64
> -
>  static inline u64 cfs_time_add_64(u64 t, u64 d)
>  {
>  	return t + d;
> @@ -79,7 +72,7 @@ static inline u64 cfs_time_add_64(u64 t, u64 d)
>  
>  static inline u64 cfs_time_shift_64(int seconds)
>  {
> -	return cfs_time_add_64(cfs_time_current_64(),
> +	return cfs_time_add_64(get_jiffies_64(),
>  			       seconds * HZ);
>  }
>  
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index 7ae2955c4db6..7df07f39b849 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -1043,7 +1043,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,
>  			 unsigned long *when)
>  {
>  	unsigned long last_alive = 0;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	rwlock_t *glock = &kiblnd_data.kib_global_lock;
>  	struct kib_peer *peer;
>  	unsigned long flags;
> @@ -1552,7 +1552,7 @@ void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int status)
>  	LIST_HEAD(zombies);
>  	struct kib_fmr_pool *fpo = fmr->fmr_pool;
>  	struct kib_fmr_poolset *fps;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	struct kib_fmr_pool *tmp;
>  	int rc;
>  
> @@ -1726,7 +1726,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
>  		goto again;
>  	}
>  
> -	if (time_before(cfs_time_current(), fps->fps_next_retry)) {
> +	if (time_before(jiffies, fps->fps_next_retry)) {
>  		/* someone failed recently */
>  		spin_unlock(&fps->fps_lock);
>  		return -EAGAIN;
> @@ -1858,7 +1858,7 @@ void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
>  	LIST_HEAD(zombies);
>  	struct kib_poolset *ps = pool->po_owner;
>  	struct kib_pool *tmp;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  
>  	spin_lock(&ps->ps_lock);
>  
> @@ -1927,7 +1927,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>  		goto again;
>  	}
>  
> -	if (time_before(cfs_time_current(), ps->ps_next_retry)) {
> +	if (time_before(jiffies, ps->ps_next_retry)) {
>  		/* someone failed recently */
>  		spin_unlock(&ps->ps_lock);
>  		return NULL;
> @@ -1937,10 +1937,10 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>  	spin_unlock(&ps->ps_lock);
>  
>  	CDEBUG(D_NET, "%s pool exhausted, allocate new pool\n", ps->ps_name);
> -	time_before = cfs_time_current();
> +	time_before = jiffies;
>  	rc = ps->ps_pool_create(ps, ps->ps_pool_size, &pool);
>  	CDEBUG(D_NET, "ps_pool_create took %lu HZ to complete",
> -	       cfs_time_current() - time_before);
> +	       jiffies - time_before);
>  
>  	spin_lock(&ps->ps_lock);
>  	ps->ps_increasing = 0;
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> index 6690a6cd4e34..c1c3277f4c1f 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> @@ -1853,8 +1853,8 @@ kiblnd_thread_fini(void)
>  static void
>  kiblnd_peer_alive(struct kib_peer *peer)
>  {
> -	/* This is racy, but everyone's only writing cfs_time_current() */
> -	peer->ibp_last_alive = cfs_time_current();
> +	/* This is racy, but everyone's only writing jiffies */
> +	peer->ibp_last_alive = jiffies;
>  	mb();
>  }
>  
> @@ -3206,7 +3206,7 @@ kiblnd_check_conns(int idx)
>  			if (timedout) {
>  				CERROR("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n",
>  				       libcfs_nid2str(peer->ibp_nid),
> -				       cfs_duration_sec(cfs_time_current() -
> +				       cfs_duration_sec(jiffies -
>  							peer->ibp_last_alive),
>  				       conn->ibc_credits,
>  				       conn->ibc_outstanding_credits,
> @@ -3681,7 +3681,7 @@ kiblnd_failover_thread(void *arg)
>  
>  		list_for_each_entry(dev, &kiblnd_data.kib_failed_devs,
>  				    ibd_fail_list) {
> -			if (time_before(cfs_time_current(),
> +			if (time_before(jiffies,
>  					dev->ibd_next_failover))
>  				continue;
>  			do_failover = 1;
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 7086678e1c3e..0efde0009a15 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -1276,7 +1276,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
>  	}
>  
>  	conn->ksnc_peer = peer;		 /* conn takes my ref on peer */
> -	peer->ksnp_last_alive = cfs_time_current();
> +	peer->ksnp_last_alive = jiffies;
>  	peer->ksnp_send_keepalive = 0;
>  	peer->ksnp_error = 0;
>  
> @@ -1284,7 +1284,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
>  	sched->kss_nconns++;
>  	conn->ksnc_scheduler = sched;
>  
> -	conn->ksnc_tx_last_post = cfs_time_current();
> +	conn->ksnc_tx_last_post = jiffies;
>  	/* Set the deadline for the outgoing HELLO to drain */
>  	conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
>  	conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> @@ -1682,8 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
>  		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
>  		       &conn->ksnc_ipaddr, conn->ksnc_port,
>  		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
> -		       cfs_duration_sec(cfs_time_sub(cfs_time_current(),
> -						     last_rcv)));
> +		       cfs_duration_sec(cfs_time_sub(jiffies, last_rcv)));
>  		lnet_finalize(conn->ksnc_peer->ksnp_ni,
>  			      conn->ksnc_cookie, -EIO);
>  		break;
> @@ -1832,7 +1831,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
>  {
>  	int connect = 1;
>  	unsigned long last_alive = 0;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	struct ksock_peer *peer = NULL;
>  	rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
>  	struct lnet_process_id id = {
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index 036fecbcede8..f97da4540b51 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -222,7 +222,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>  			 */
>  			conn->ksnc_tx_deadline =
>  				cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> -			conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
> +			conn->ksnc_peer->ksnp_last_alive = jiffies;
>  			conn->ksnc_tx_bufnob = bufnob;
>  			mb();
>  		}
> @@ -267,7 +267,7 @@ ksocknal_recv_iter(struct ksock_conn *conn)
>  	/* received something... */
>  	nob = rc;
>  
> -	conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
> +	conn->ksnc_peer->ksnp_last_alive = jiffies;
>  	conn->ksnc_rx_deadline =
>  		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>  	mb();		       /* order with setting rx_started */
> @@ -481,7 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>  		LASSERT(conn->ksnc_tx_scheduled);
>  		list_add_tail(&conn->ksnc_tx_list,
>  			      &ksocknal_data.ksnd_enomem_conns);
> -		if (!cfs_time_aftereq(cfs_time_add(cfs_time_current(),
> +		if (!cfs_time_aftereq(cfs_time_add(jiffies,
>  						   SOCKNAL_ENOMEM_RETRY),
>  				   ksocknal_data.ksnd_reaper_waketime))
>  			wake_up(&ksocknal_data.ksnd_reaper_waitq);
> @@ -612,7 +612,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
>  	conn = (typed) ? typed : fallback;
>  
>  	if (conn)
> -		conn->ksnc_tx_last_post = cfs_time_current();
> +		conn->ksnc_tx_last_post = jiffies;
>  
>  	return conn;
>  }
> @@ -680,7 +680,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
>  		conn->ksnc_tx_deadline =
>  			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>  		if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
> -			conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
> +			conn->ksnc_peer->ksnp_last_alive = jiffies;
>  		conn->ksnc_tx_bufnob = 0;
>  		mb(); /* order with adding to tx_queue */
>  	}
> @@ -728,7 +728,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
>  struct ksock_route *
>  ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
>  {
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	struct list_head *tmp;
>  	struct ksock_route *route;
>  
> @@ -1777,7 +1777,7 @@ ksocknal_connect(struct ksock_route *route)
>  	int retry_later = 0;
>  	int rc = 0;
>  
> -	deadline = cfs_time_add(cfs_time_current(),
> +	deadline = cfs_time_add(jiffies,
>  				*ksocknal_tunables.ksnd_timeout * HZ);
>  
>  	write_lock_bh(&ksocknal_data.ksnd_global_lock);
> @@ -1825,7 +1825,7 @@ ksocknal_connect(struct ksock_route *route)
>  
>  		write_unlock_bh(&ksocknal_data.ksnd_global_lock);
>  
> -		if (cfs_time_aftereq(cfs_time_current(), deadline)) {
> +		if (cfs_time_aftereq(jiffies, deadline)) {
>  			rc = -ETIMEDOUT;
>  			lnet_connect_console_error(rc, peer->ksnp_id.nid,
>  						   route->ksnr_ipaddr,
> @@ -1877,7 +1877,7 @@ ksocknal_connect(struct ksock_route *route)
>  			 */
>  			route->ksnr_retry_interval =
>  				*ksocknal_tunables.ksnd_min_reconnectms * HZ / 1000;
> -			route->ksnr_timeout = cfs_time_add(cfs_time_current(),
> +			route->ksnr_timeout = cfs_time_add(jiffies,
>  							   route->ksnr_retry_interval);
>  		}
>  
> @@ -1903,7 +1903,7 @@ ksocknal_connect(struct ksock_route *route)
>  		    (long)*ksocknal_tunables.ksnd_max_reconnectms * HZ / 1000);
>  
>  	LASSERT(route->ksnr_retry_interval);
> -	route->ksnr_timeout = cfs_time_add(cfs_time_current(),
> +	route->ksnr_timeout = cfs_time_add(jiffies,
>  					   route->ksnr_retry_interval);
>  
>  	if (!list_empty(&peer->ksnp_tx_queue) &&
> @@ -2050,7 +2050,7 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
>  	struct ksock_route *route;
>  	unsigned long now;
>  
> -	now = cfs_time_current();
> +	now = jiffies;
>  
>  	/* connd_routes can contain both pending and ordinary routes */
>  	list_for_each_entry(route, &ksocknal_data.ksnd_connd_routes,
> @@ -2228,7 +2228,7 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
>  		}
>  
>  		if (conn->ksnc_rx_started &&
> -		    cfs_time_aftereq(cfs_time_current(),
> +		    cfs_time_aftereq(jiffies,
>  				     conn->ksnc_rx_deadline)) {
>  			/* Timed out incomplete incoming message */
>  			ksocknal_conn_addref(conn);
> @@ -2244,7 +2244,7 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
>  
>  		if ((!list_empty(&conn->ksnc_tx_queue) ||
>  		     conn->ksnc_sock->sk->sk_wmem_queued) &&
> -		    cfs_time_aftereq(cfs_time_current(),
> +		    cfs_time_aftereq(jiffies,
>  				     conn->ksnc_tx_deadline)) {
>  			/*
>  			 * Timed out messages queued for sending or
> @@ -2272,7 +2272,7 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer)
>  	write_lock_bh(&ksocknal_data.ksnd_global_lock);
>  
>  	list_for_each_entry_safe(tx, tmp, &peer->ksnp_tx_queue, tx_list) {
> -		if (!cfs_time_aftereq(cfs_time_current(),
> +		if (!cfs_time_aftereq(jiffies,
>  				      tx->tx_deadline))
>  			break;
>  
> @@ -2301,12 +2301,12 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
>  		return 0;
>  
>  	if (*ksocknal_tunables.ksnd_keepalive <= 0 ||
> -	    time_before(cfs_time_current(),
> +	    time_before(jiffies,
>  			cfs_time_add(peer->ksnp_last_alive,
>  				     *ksocknal_tunables.ksnd_keepalive * HZ)))
>  		return 0;
>  
> -	if (time_before(cfs_time_current(), peer->ksnp_send_keepalive))
> +	if (time_before(jiffies, peer->ksnp_send_keepalive))
>  		return 0;
>  
>  	/*
> @@ -2400,7 +2400,7 @@ ksocknal_check_peer_timeouts(int idx)
>  			tx = list_entry(peer->ksnp_tx_queue.next,
>  					struct ksock_tx, tx_list);
>  
> -			if (cfs_time_aftereq(cfs_time_current(),
> +			if (cfs_time_aftereq(jiffies,
>  					     tx->tx_deadline)) {
>  				ksocknal_peer_addref(peer);
>  				read_unlock(&ksocknal_data.ksnd_global_lock);
> @@ -2418,7 +2418,7 @@ ksocknal_check_peer_timeouts(int idx)
>  		tx_stale = NULL;
>  		spin_lock(&peer->ksnp_lock);
>  		list_for_each_entry(tx, &peer->ksnp_zc_req_list, tx_zc_list) {
> -			if (!cfs_time_aftereq(cfs_time_current(),
> +			if (!cfs_time_aftereq(jiffies,
>  					      tx->tx_deadline))
>  				break;
>  			/* ignore the TX if connection is being closed */
> @@ -2444,7 +2444,7 @@ ksocknal_check_peer_timeouts(int idx)
>  
>  		CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n",
>  		       n, libcfs_nid2str(peer->ksnp_id.nid), tx_stale,
> -		       cfs_duration_sec(cfs_time_current() - deadline),
> +		       cfs_duration_sec(jiffies - deadline),
>  		       resid, conn->ksnc_sock->sk->sk_wmem_queued);
>  
>  		ksocknal_close_conn_and_siblings(conn, -ETIMEDOUT);
> @@ -2466,7 +2466,7 @@ ksocknal_reaper(void *arg)
>  	long timeout;
>  	int i;
>  	int peer_index = 0;
> -	unsigned long deadline = cfs_time_current();
> +	unsigned long deadline = jiffies;
>  
>  	INIT_LIST_HEAD(&enomem_conns);
>  	init_waitqueue_entry(&wait, current);
> @@ -2532,7 +2532,7 @@ ksocknal_reaper(void *arg)
>  
>  		/* careful with the jiffy wrap... */
>  		while ((timeout = cfs_time_sub(deadline,
> -					       cfs_time_current())) <= 0) {
> +					       jiffies)) <= 0) {
>  			const int n = 4;
>  			const int p = 1;
>  			int chunk = ksocknal_data.ksnd_peer_hash_size;
> @@ -2569,7 +2569,7 @@ ksocknal_reaper(void *arg)
>  			timeout = SOCKNAL_ENOMEM_RETRY;
>  		}
>  		ksocknal_data.ksnd_reaper_waketime =
> -			cfs_time_add(cfs_time_current(), timeout);
> +			cfs_time_add(jiffies, timeout);
>  
>  		set_current_state(TASK_INTERRUPTIBLE);
>  		add_wait_queue(&ksocknal_data.ksnd_reaper_waitq, &wait);
> diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> index 4affca750bc5..2aeae0331ee0 100644
> --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
> +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> @@ -431,7 +431,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  	if (cdls) {
>  		if (libcfs_console_ratelimit &&
>  		    cdls->cdls_next &&		/* not first time ever */
> -		    !cfs_time_after(cfs_time_current(), cdls->cdls_next)) {
> +		    !cfs_time_after(jiffies, cdls->cdls_next)) {
>  			/* skipping a console message */
>  			cdls->cdls_count++;
>  			if (tcd)
> @@ -439,7 +439,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  			return 1;
>  		}
>  
> -		if (cfs_time_after(cfs_time_current(),
> +		if (cfs_time_after(jiffies,
>  				   cdls->cdls_next + libcfs_console_max_delay +
>  				   10 * HZ)) {
>  			/* last timeout was a long time ago */
> @@ -454,7 +454,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  			cdls->cdls_delay = libcfs_console_max_delay;
>  
>  		/* ensure cdls_next is never zero after it's been seen */
> -		cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1;
> +		cdls->cdls_next = (jiffies + cdls->cdls_delay) | 1;
>  	}
>  
>  	if (tcd) {
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
> index ed43b3f4b114..289ed876bd81 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-move.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
> @@ -501,7 +501,7 @@ lnet_ni_query_locked(struct lnet_ni *ni, struct lnet_peer *lp)
>  	ni->ni_lnd->lnd_query(ni, lp->lp_nid, &last_alive);
>  	lnet_net_lock(lp->lp_cpt);
>  
> -	lp->lp_last_query = cfs_time_current();
> +	lp->lp_last_query = jiffies;
>  
>  	if (last_alive) /* NI has updated timestamp */
>  		lp->lp_last_alive = last_alive;
> @@ -545,7 +545,7 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
>  static int
>  lnet_peer_alive_locked(struct lnet_peer *lp)
>  {
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  
>  	if (!lnet_peer_aliveness_enabled(lp))
>  		return -ENODEV;
> diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
> index a63b7941d435..3928e9a74d6f 100644
> --- a/drivers/staging/lustre/lnet/lnet/net_fault.c
> +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
> @@ -306,7 +306,7 @@ drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
>  	/* match this rule, check drop rate now */
>  	spin_lock(&rule->dr_lock);
>  	if (rule->dr_drop_time) { /* time based drop */
> -		unsigned long now = cfs_time_current();
> +		unsigned long now = jiffies;
>  
>  		rule->dr_stat.fs_count++;
>  		drop = cfs_time_aftereq(now, rule->dr_drop_time);
> @@ -472,7 +472,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
>  	/* match this rule, check delay rate now */
>  	spin_lock(&rule->dl_lock);
>  	if (rule->dl_delay_time) { /* time based delay */
> -		unsigned long now = cfs_time_current();
> +		unsigned long now = jiffies;
>  
>  		rule->dl_stat.fs_count++;
>  		delay = cfs_time_aftereq(now, rule->dl_delay_time);
> @@ -562,7 +562,7 @@ delayed_msg_check(struct lnet_delay_rule *rule, bool all,
>  {
>  	struct lnet_msg *msg;
>  	struct lnet_msg *tmp;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  
>  	if (!all && rule->dl_msg_send > now)
>  		return;
> diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
> index 3d4caa609c83..58294149f7b2 100644
> --- a/drivers/staging/lustre/lnet/lnet/peer.c
> +++ b/drivers/staging/lustre/lnet/lnet/peer.c
> @@ -315,7 +315,7 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
>  	lp->lp_alive_count = 0;
>  	lp->lp_timestamp = 0;
>  	lp->lp_alive = !lnet_peers_start_down(); /* 1 bit!! */
> -	lp->lp_last_alive = cfs_time_current(); /* assumes alive */
> +	lp->lp_last_alive = jiffies; /* assumes alive */
>  	lp->lp_last_query = 0; /* haven't asked NI yet */
>  	lp->lp_ping_timestamp = 0;
>  	lp->lp_ping_feats = LNET_PING_FEAT_INVAL;
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index a3c3f4959f46..ac9b392a0afa 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -765,7 +765,7 @@ lnet_router_checker_event(struct lnet_event *event)
>  	 * we ping alive routers to try to detect router death before
>  	 * apps get burned).
>  	 */
> -	lnet_notify_locked(lp, 1, !event->status, cfs_time_current());
> +	lnet_notify_locked(lp, 1, !event->status, jiffies);
>  
>  	/*
>  	 * The router checker will wake up very shortly and do the
> @@ -976,7 +976,7 @@ static void
>  lnet_ping_router_locked(struct lnet_peer *rtr)
>  {
>  	struct lnet_rc_data *rcd = NULL;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	int secs;
>  
>  	lnet_peer_addref_locked(rtr);
> @@ -1730,7 +1730,7 @@ int
>  lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
>  {
>  	struct lnet_peer *lp = NULL;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	int cpt = lnet_cpt_of_nid(nid);
>  
>  	LASSERT(!in_interrupt());
> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
> index 1a71ffebc889..315d067540c0 100644
> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c
> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
> @@ -324,7 +324,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
>  
>  		if (peer) {
>  			lnet_nid_t nid = peer->lp_nid;
> -			unsigned long now = cfs_time_current();
> +			unsigned long now = jiffies;
>  			unsigned long deadline = peer->lp_ping_deadline;
>  			int nrefs = peer->lp_refcount;
>  			int nrtrrefs = peer->lp_rtr_refcount;
> @@ -509,7 +509,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
>  				aliveness = peer->lp_alive ? "up" : "down";
>  
>  			if (lnet_peer_aliveness_enabled(peer)) {
> -				unsigned long now = cfs_time_current();
> +				unsigned long now = jiffies;
>  				long delta;
>  
>  				delta = cfs_time_sub(now, peer->lp_last_alive);
> diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
> index 6dcc966b293b..68e06e06857d 100644
> --- a/drivers/staging/lustre/lnet/selftest/conrpc.c
> +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
> @@ -75,7 +75,7 @@ lstcon_rpc_done(struct srpc_client_rpc *rpc)
>  		/* not aborted */
>  		LASSERT(!crpc->crp_status);
>  
> -		crpc->crp_stamp = cfs_time_current();
> +		crpc->crp_stamp = jiffies;
>  		crpc->crp_status = rpc->crpc_status;
>  	}
>  
> @@ -297,14 +297,14 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
>  		if (!crpc->crp_posted || /* not posted */
>  		    crpc->crp_stamp) {	 /* rpc done or aborted already */
>  			if (!crpc->crp_stamp) {
> -				crpc->crp_stamp = cfs_time_current();
> +				crpc->crp_stamp = jiffies;
>  				crpc->crp_status = -EINTR;
>  			}
>  			spin_unlock(&rpc->crpc_lock);
>  			continue;
>  		}
>  
> -		crpc->crp_stamp = cfs_time_current();
> +		crpc->crp_stamp = jiffies;
>  		crpc->crp_status = error;
>  
>  		spin_unlock(&rpc->crpc_lock);
> diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
> index 1acd5cb324b1..1889f1e86473 100644
> --- a/drivers/staging/lustre/lnet/selftest/console.c
> +++ b/drivers/staging/lustre/lnet/selftest/console.c
> @@ -98,7 +98,7 @@ lstcon_node_find(struct lnet_process_id id, struct lstcon_node **ndpp,
>  
>  	ndl->ndl_node->nd_ref = 1;
>  	ndl->ndl_node->nd_id = id;
> -	ndl->ndl_node->nd_stamp = cfs_time_current();
> +	ndl->ndl_node->nd_stamp = jiffies;
>  	ndl->ndl_node->nd_state = LST_NODE_UNKNOWN;
>  	ndl->ndl_node->nd_timeout = 0;
>  	memset(&ndl->ndl_node->nd_ping, 0, sizeof(struct lstcon_rpc));
> @@ -1701,7 +1701,7 @@ lstcon_new_session_id(struct lst_sid *sid)
>  
>  	LNetGetId(1, &id);
>  	sid->ses_nid = id.nid;
> -	sid->ses_stamp = cfs_time_current();
> +	sid->ses_stamp = jiffies;
>  }
>  
>  int
> diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
> index 0ca1e3a780ca..045eecd23e0a 100644
> --- a/drivers/staging/lustre/lnet/selftest/framework.c
> +++ b/drivers/staging/lustre/lnet/selftest/framework.c
> @@ -272,7 +272,7 @@ sfw_init_session(struct sfw_session *sn, struct lst_sid sid,
>  	sn->sn_id = sid;
>  	sn->sn_features = features;
>  	sn->sn_timeout = session_timeout;
> -	sn->sn_started = cfs_time_current();
> +	sn->sn_started = jiffies;
>  
>  	timer->stt_data = sn;
>  	timer->stt_func = sfw_session_expired;
> diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
> index d35ae0cda8d2..f4824d8ec741 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_net.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_net.h
> @@ -2255,7 +2255,7 @@ static inline int ptlrpc_send_limit_expired(struct ptlrpc_request *req)
>  	if (req->rq_delay_limit != 0 &&
>  	    time_before(cfs_time_add(req->rq_queued_time,
>  				     req->rq_delay_limit * HZ),
> -			cfs_time_current())) {
> +			jiffies)) {
>  		return 1;
>  	}
>  	return 0;
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> index f24dd74ffa09..7cfc3c8d100c 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -913,7 +913,7 @@ static inline int obd_destroy_export(struct obd_export *exp)
>  /*
>   * @max_age is the oldest time in jiffies that we accept using a cached data.
>   * If the cache is older than @max_age we will get a new value from the
> - * target.  Use a value of "cfs_time_current() + HZ" to guarantee freshness.
> + * target.  Use a value of "jiffies + HZ" to guarantee freshness.
>   */
>  static inline int obd_statfs_async(struct obd_export *exp,
>  				   struct obd_info *oinfo,
> @@ -975,7 +975,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp,
>  /*
>   * @max_age is the oldest time in jiffies that we accept using a cached data.
>   * If the cache is older than @max_age we will get a new value from the
> - * target.  Use a value of "cfs_time_current() + HZ" to guarantee freshness.
> + * target.  Use a value of "jiffies + HZ" to guarantee freshness.
>   */
>  static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
>  			     struct obd_statfs *osfs, __u64 max_age,
> @@ -997,7 +997,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
>  		if (rc == 0) {
>  			spin_lock(&obd->obd_osfs_lock);
>  			memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
> -			obd->obd_osfs_age = cfs_time_current_64();
> +			obd->obd_osfs_age = get_jiffies_64();
>  			spin_unlock(&obd->obd_osfs_lock);
>  		}
>  	} else {
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> index 614caa4a9b0e..22c49cc593e3 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> @@ -243,7 +243,7 @@ static void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock)
>  {
>  	struct ldlm_namespace *ns = ldlm_lock_to_ns(lock);
>  
> -	lock->l_last_used = cfs_time_current();
> +	lock->l_last_used = jiffies;
>  	LASSERT(list_empty(&lock->l_lru));
>  	LASSERT(lock->l_resource->lr_type != LDLM_FLOCK);
>  	list_add_tail(&lock->l_lru, &ns->ns_unused_list);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> index c772c68e5a49..ab4dd15c8dd4 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> @@ -325,7 +325,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
>  	lock_res_and_lock(lock);
>  	if (lock->l_granted_mode == LCK_PW &&
>  	    !lock->l_readers && !lock->l_writers &&
> -	    cfs_time_after(cfs_time_current(),
> +	    cfs_time_after(jiffies,
>  			   cfs_time_add(lock->l_last_used,
>  					10 * HZ))) {
>  		unlock_res_and_lock(lock);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index 8e79f5e073ff..0e1b21c1f06d 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -116,7 +116,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
>  			   (s64)lock->l_last_activity,
>  			   (s64)(ktime_get_real_seconds() -
>  				 lock->l_last_activity));
> -		if (cfs_time_after(cfs_time_current(), next_dump)) {
> +		if (cfs_time_after(jiffies, next_dump)) {
>  			last_dump = next_dump;
>  			next_dump = cfs_time_shift(300);
>  			ldlm_namespace_dump(D_DLMTRACE,
> @@ -1161,7 +1161,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
>  						    int unused, int added,
>  						    int count)
>  {
> -	unsigned long cur = cfs_time_current();
> +	unsigned long cur = jiffies;
>  	struct ldlm_pool *pl = &ns->ns_pool;
>  	__u64 slv, lvf, lv;
>  	unsigned long la;
> @@ -1176,7 +1176,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
>  	 * Despite of the LV, It doesn't make sense to keep the lock which
>  	 * is unused for ns_max_age time.
>  	 */
> -	if (cfs_time_after(cfs_time_current(),
> +	if (cfs_time_after(jiffies,
>  			   cfs_time_add(lock->l_last_used, ns->ns_max_age)))
>  		return LDLM_POLICY_CANCEL_LOCK;
>  
> @@ -1233,7 +1233,7 @@ static enum ldlm_policy_res ldlm_cancel_aged_policy(struct ldlm_namespace *ns,
>  						    int count)
>  {
>  	if ((added >= count) &&
> -	    time_before(cfs_time_current(),
> +	    time_before(jiffies,
>  			cfs_time_add(lock->l_last_used, ns->ns_max_age)))
>  		return LDLM_POLICY_KEEP_LOCK;
>  
> @@ -1380,7 +1380,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
>  				continue;
>  
>  			last_use = lock->l_last_used;
> -			if (last_use == cfs_time_current())
> +			if (last_use == jiffies)
>  				continue;
>  
>  			/* Somebody is already doing CANCEL. No need for this
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> index 8841a1bb2c0a..ccd0c082e39b 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> @@ -1316,7 +1316,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
>  	CDEBUG(level, "--- Namespace: %s (rc: %d, side: client)\n",
>  	       ldlm_ns_name(ns), atomic_read(&ns->ns_bref));
>  
> -	if (time_before(cfs_time_current(), ns->ns_next_dump))
> +	if (time_before(jiffies, ns->ns_next_dump))
>  		return;
>  
>  	cfs_hash_for_each_nolock(ns->ns_rs_hash,
> diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
> index d46bcf71b273..6504850e3689 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_internal.h
> +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
> @@ -1110,7 +1110,7 @@ static inline int ll_glimpse_size(struct inode *inode)
>  
>  	down_read(&lli->lli_glimpse_sem);
>  	rc = cl_glimpse_size(inode);
> -	lli->lli_glimpse_time = cfs_time_current();
> +	lli->lli_glimpse_time = jiffies;
>  	up_read(&lli->lli_glimpse_sem);
>  	return rc;
>  }
> diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
> index 155ce3cf6f60..6f996acf6aa8 100644
> --- a/drivers/staging/lustre/lustre/llite/statahead.c
> +++ b/drivers/staging/lustre/lustre/llite/statahead.c
> @@ -535,7 +535,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
>  
>  	cl_agl(inode);
>  	lli->lli_agl_index = 0;
> -	lli->lli_glimpse_time = cfs_time_current();
> +	lli->lli_glimpse_time = jiffies;
>  	up_write(&lli->lli_glimpse_sem);
>  
>  	CDEBUG(D_READA, "Handled (init) async glimpse: inode= "
> diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
> index 051450d67524..41fc023cc381 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_request.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_request.c
> @@ -160,7 +160,7 @@ static int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,
>  
>  		spin_lock(&obd->obd_osfs_lock);
>  		memcpy(&obd->obd_osfs, osfs, sizeof(*osfs));
> -		obd->obd_osfs_age = cfs_time_current_64();
> +		obd->obd_osfs_age = get_jiffies_64();
>  		spin_unlock(&obd->obd_osfs_lock);
>  		return 0;
>  	}
> @@ -277,7 +277,7 @@ static int cb_statfs_update(void *cookie, int rc)
>  	spin_lock(&tgtobd->obd_osfs_lock);
>  	memcpy(&tgtobd->obd_osfs, lov_sfs, sizeof(*lov_sfs));
>  	if ((oinfo->oi_flags & OBD_STATFS_FROM_CACHE) == 0)
> -		tgtobd->obd_osfs_age = cfs_time_current_64();
> +		tgtobd->obd_osfs_age = get_jiffies_64();
>  	spin_unlock(&tgtobd->obd_osfs_lock);
>  
>  out_update:
> diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
> index 459503727ce3..ba4a4bf3b0f1 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_cache.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
> @@ -1290,7 +1290,7 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
>  
>  	result = cl_page_make_ready(env, page, CRT_WRITE);
>  	if (result == 0)
> -		opg->ops_submit_time = cfs_time_current();
> +		opg->ops_submit_time = jiffies;
>  	return result;
>  }
>  
> diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
> index 9582d5a642e2..c5dc894a4c1b 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_object.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_object.c
> @@ -300,7 +300,7 @@ static int osc_object_fiemap(const struct lu_env *env, struct cl_object *obj,
>  
>  void osc_object_set_contended(struct osc_object *obj)
>  {
> -	obj->oo_contention_time = cfs_time_current();
> +	obj->oo_contention_time = jiffies;
>  	/* mb(); */
>  	obj->oo_contended = 1;
>  }
> @@ -314,7 +314,7 @@ int osc_object_is_contended(struct osc_object *obj)
>  {
>  	struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
>  	int osc_contention_time = dev->od_contention_time;
> -	unsigned long cur_time = cfs_time_current();
> +	unsigned long cur_time = jiffies;
>  	unsigned long retry_time;
>  
>  	if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
> diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
> index 01a930dbbf64..20c553ef3a5e 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_page.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_page.c
> @@ -125,7 +125,7 @@ static inline unsigned long osc_submit_duration(struct osc_page *opg)
>  	if (opg->ops_submit_time == 0)
>  		return 0;
>  
> -	return (cfs_time_current() - opg->ops_submit_time);
> +	return (jiffies - opg->ops_submit_time);
>  }
>  
>  static int osc_page_print(const struct lu_env *env,
> @@ -312,7 +312,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
>  		oap->oap_cmd |= OBD_BRW_NOQUOTA;
>  	}
>  
> -	opg->ops_submit_time = cfs_time_current();
> +	opg->ops_submit_time = jiffies;
>  	osc_page_transfer_get(opg, "transfer\0imm");
>  	osc_page_transfer_add(env, opg, crt);
>  }
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 1c2bbbf5d864..9966fc7af789 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -741,7 +741,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
>  
>  static int osc_should_shrink_grant(struct client_obd *client)
>  {
> -	unsigned long time = cfs_time_current();
> +	unsigned long time = jiffies;
>  	unsigned long next_shrink = client->cl_next_shrink_grant;
>  
>  	if ((client->cl_import->imp_connect_data.ocd_connect_flags &
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
> index ca096fadb9c0..eeb281266413 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/client.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
> @@ -1050,7 +1050,7 @@ void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
>  	list_add_tail(&req->rq_set_chain, &set->set_requests);
>  	req->rq_set = set;
>  	atomic_inc(&set->set_remaining);
> -	req->rq_queued_time = cfs_time_current();
> +	req->rq_queued_time = jiffies;
>  
>  	if (req->rq_reqmsg)
>  		lustre_msg_set_jobid(req->rq_reqmsg, NULL);
> @@ -1081,7 +1081,7 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
>  	spin_lock(&set->set_new_req_lock);
>  	/* The set takes over the caller's request reference.  */
>  	req->rq_set = set;
> -	req->rq_queued_time = cfs_time_current();
> +	req->rq_queued_time = jiffies;
>  	list_add_tail(&req->rq_set_chain, &set->set_new_requests);
>  	count = atomic_inc_return(&set->set_new_count);
>  	spin_unlock(&set->set_new_req_lock);
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index a2c4fc3488b1..4a9d1f189d01 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -508,7 +508,7 @@ static int import_select_connection(struct obd_import *imp)
>  		       imp->imp_obd->obd_name, at_get(at));
>  	}
>  
> -	imp_conn->oic_last_attempt = cfs_time_current_64();
> +	imp_conn->oic_last_attempt = get_jiffies_64();
>  
>  	/* switch connection, don't mind if it's same as the current one */
>  	ptlrpc_connection_put(imp->imp_connection);
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> index 0775b7a048bb..57c7db47e249 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> @@ -142,7 +142,7 @@ static long pinger_check_timeout(unsigned long time)
>  	mutex_unlock(&pinger_mutex);
>  
>  	return cfs_time_sub(cfs_time_add(time, timeout * HZ),
> -					 cfs_time_current());
> +					 jiffies);
>  }
>  
>  static bool ir_up;
> @@ -223,7 +223,7 @@ static DECLARE_DELAYED_WORK(ping_work, ptlrpc_pinger_main);
>  
>  static void ptlrpc_pinger_main(struct work_struct *ws)
>  {
> -	unsigned long this_ping = cfs_time_current();
> +	unsigned long this_ping = jiffies;
>  	long time_to_next_wake;
>  	struct timeout_item *item;
>  	struct obd_import *imp;
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
> index f37364e00dfe..fc29efbd9914 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
> @@ -336,7 +336,7 @@ static void ptlrpc_at_timer(struct timer_list *t)
>  	svcpt = from_timer(svcpt, t, scp_at_timer);
>  
>  	svcpt->scp_at_check = 1;
> -	svcpt->scp_at_checktime = cfs_time_current();
> +	svcpt->scp_at_checktime = jiffies;
>  	wake_up(&svcpt->scp_waitq);
>  }
>  
> @@ -1153,7 +1153,7 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
>  		spin_unlock(&svcpt->scp_at_lock);
>  		return;
>  	}
> -	delay = cfs_time_sub(cfs_time_current(), svcpt->scp_at_checktime);
> +	delay = cfs_time_sub(jiffies, svcpt->scp_at_checktime);
>  	svcpt->scp_at_check = 0;
>  
>  	if (array->paa_count == 0) {
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 09/17] staging: lustre: cfs_time_current() -> jiffies.
@ 2018-03-30 19:00     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:00 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> Discard cfs_time_current() and cfs_time_current64()
> and use jiffies and get_jiffies_64() like the rest of the kernel.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/libcfs_time.h      |    2 -
>  .../lustre/include/linux/libcfs/linux/linux-time.h |    9 ----
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   14 +++---
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    8 ++--
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    9 ++--
>  .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   44 ++++++++++----------
>  drivers/staging/lustre/lnet/libcfs/tracefile.c     |    6 +--
>  drivers/staging/lustre/lnet/lnet/lib-move.c        |    4 +-
>  drivers/staging/lustre/lnet/lnet/net_fault.c       |    6 +--
>  drivers/staging/lustre/lnet/lnet/peer.c            |    2 -
>  drivers/staging/lustre/lnet/lnet/router.c          |    6 +--
>  drivers/staging/lustre/lnet/lnet/router_proc.c     |    4 +-
>  drivers/staging/lustre/lnet/selftest/conrpc.c      |    6 +--
>  drivers/staging/lustre/lnet/selftest/console.c     |    4 +-
>  drivers/staging/lustre/lnet/selftest/framework.c   |    2 -
>  drivers/staging/lustre/lustre/include/lustre_net.h |    2 -
>  drivers/staging/lustre/lustre/include/obd_class.h  |    6 +--
>  drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |    2 -
>  drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    2 -
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   10 ++---
>  drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 -
>  .../staging/lustre/lustre/llite/llite_internal.h   |    2 -
>  drivers/staging/lustre/lustre/llite/statahead.c    |    2 -
>  drivers/staging/lustre/lustre/lov/lov_request.c    |    4 +-
>  drivers/staging/lustre/lustre/osc/osc_cache.c      |    2 -
>  drivers/staging/lustre/lustre/osc/osc_object.c     |    4 +-
>  drivers/staging/lustre/lustre/osc/osc_page.c       |    4 +-
>  drivers/staging/lustre/lustre/osc/osc_request.c    |    2 -
>  drivers/staging/lustre/lustre/ptlrpc/client.c      |    4 +-
>  drivers/staging/lustre/lustre/ptlrpc/import.c      |    2 -
>  drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    4 +-
>  drivers/staging/lustre/lustre/ptlrpc/service.c     |    4 +-
>  32 files changed, 88 insertions(+), 96 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> index c4f25be78268..df7a3f13f3b3 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> @@ -62,7 +62,7 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
>  
>  static inline unsigned long cfs_time_shift(int seconds)
>  {
> -	return cfs_time_add(cfs_time_current(), seconds * HZ);
> +	return cfs_time_add(jiffies, seconds * HZ);
>  }
>  
>  /*
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index 805cb326af86..ba115e8c820f 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -60,18 +60,11 @@
>   * Generic kernel stuff
>   */
>  
> -static inline unsigned long cfs_time_current(void)
> -{
> -	return jiffies;
> -}
> -
>  static inline long cfs_duration_sec(long d)
>  {
>  	return d / msecs_to_jiffies(MSEC_PER_SEC);
>  }
>  
> -#define cfs_time_current_64 get_jiffies_64
> -
>  static inline u64 cfs_time_add_64(u64 t, u64 d)
>  {
>  	return t + d;
> @@ -79,7 +72,7 @@ static inline u64 cfs_time_add_64(u64 t, u64 d)
>  
>  static inline u64 cfs_time_shift_64(int seconds)
>  {
> -	return cfs_time_add_64(cfs_time_current_64(),
> +	return cfs_time_add_64(get_jiffies_64(),
>  			       seconds * HZ);
>  }
>  
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index 7ae2955c4db6..7df07f39b849 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -1043,7 +1043,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,
>  			 unsigned long *when)
>  {
>  	unsigned long last_alive = 0;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	rwlock_t *glock = &kiblnd_data.kib_global_lock;
>  	struct kib_peer *peer;
>  	unsigned long flags;
> @@ -1552,7 +1552,7 @@ void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int status)
>  	LIST_HEAD(zombies);
>  	struct kib_fmr_pool *fpo = fmr->fmr_pool;
>  	struct kib_fmr_poolset *fps;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	struct kib_fmr_pool *tmp;
>  	int rc;
>  
> @@ -1726,7 +1726,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
>  		goto again;
>  	}
>  
> -	if (time_before(cfs_time_current(), fps->fps_next_retry)) {
> +	if (time_before(jiffies, fps->fps_next_retry)) {
>  		/* someone failed recently */
>  		spin_unlock(&fps->fps_lock);
>  		return -EAGAIN;
> @@ -1858,7 +1858,7 @@ void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
>  	LIST_HEAD(zombies);
>  	struct kib_poolset *ps = pool->po_owner;
>  	struct kib_pool *tmp;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  
>  	spin_lock(&ps->ps_lock);
>  
> @@ -1927,7 +1927,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>  		goto again;
>  	}
>  
> -	if (time_before(cfs_time_current(), ps->ps_next_retry)) {
> +	if (time_before(jiffies, ps->ps_next_retry)) {
>  		/* someone failed recently */
>  		spin_unlock(&ps->ps_lock);
>  		return NULL;
> @@ -1937,10 +1937,10 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>  	spin_unlock(&ps->ps_lock);
>  
>  	CDEBUG(D_NET, "%s pool exhausted, allocate new pool\n", ps->ps_name);
> -	time_before = cfs_time_current();
> +	time_before = jiffies;
>  	rc = ps->ps_pool_create(ps, ps->ps_pool_size, &pool);
>  	CDEBUG(D_NET, "ps_pool_create took %lu HZ to complete",
> -	       cfs_time_current() - time_before);
> +	       jiffies - time_before);
>  
>  	spin_lock(&ps->ps_lock);
>  	ps->ps_increasing = 0;
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> index 6690a6cd4e34..c1c3277f4c1f 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> @@ -1853,8 +1853,8 @@ kiblnd_thread_fini(void)
>  static void
>  kiblnd_peer_alive(struct kib_peer *peer)
>  {
> -	/* This is racy, but everyone's only writing cfs_time_current() */
> -	peer->ibp_last_alive = cfs_time_current();
> +	/* This is racy, but everyone's only writing jiffies */
> +	peer->ibp_last_alive = jiffies;
>  	mb();
>  }
>  
> @@ -3206,7 +3206,7 @@ kiblnd_check_conns(int idx)
>  			if (timedout) {
>  				CERROR("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n",
>  				       libcfs_nid2str(peer->ibp_nid),
> -				       cfs_duration_sec(cfs_time_current() -
> +				       cfs_duration_sec(jiffies -
>  							peer->ibp_last_alive),
>  				       conn->ibc_credits,
>  				       conn->ibc_outstanding_credits,
> @@ -3681,7 +3681,7 @@ kiblnd_failover_thread(void *arg)
>  
>  		list_for_each_entry(dev, &kiblnd_data.kib_failed_devs,
>  				    ibd_fail_list) {
> -			if (time_before(cfs_time_current(),
> +			if (time_before(jiffies,
>  					dev->ibd_next_failover))
>  				continue;
>  			do_failover = 1;
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 7086678e1c3e..0efde0009a15 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -1276,7 +1276,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
>  	}
>  
>  	conn->ksnc_peer = peer;		 /* conn takes my ref on peer */
> -	peer->ksnp_last_alive = cfs_time_current();
> +	peer->ksnp_last_alive = jiffies;
>  	peer->ksnp_send_keepalive = 0;
>  	peer->ksnp_error = 0;
>  
> @@ -1284,7 +1284,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
>  	sched->kss_nconns++;
>  	conn->ksnc_scheduler = sched;
>  
> -	conn->ksnc_tx_last_post = cfs_time_current();
> +	conn->ksnc_tx_last_post = jiffies;
>  	/* Set the deadline for the outgoing HELLO to drain */
>  	conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
>  	conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> @@ -1682,8 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
>  		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
>  		       &conn->ksnc_ipaddr, conn->ksnc_port,
>  		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
> -		       cfs_duration_sec(cfs_time_sub(cfs_time_current(),
> -						     last_rcv)));
> +		       cfs_duration_sec(cfs_time_sub(jiffies, last_rcv)));
>  		lnet_finalize(conn->ksnc_peer->ksnp_ni,
>  			      conn->ksnc_cookie, -EIO);
>  		break;
> @@ -1832,7 +1831,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
>  {
>  	int connect = 1;
>  	unsigned long last_alive = 0;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	struct ksock_peer *peer = NULL;
>  	rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
>  	struct lnet_process_id id = {
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index 036fecbcede8..f97da4540b51 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -222,7 +222,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>  			 */
>  			conn->ksnc_tx_deadline =
>  				cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> -			conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
> +			conn->ksnc_peer->ksnp_last_alive = jiffies;
>  			conn->ksnc_tx_bufnob = bufnob;
>  			mb();
>  		}
> @@ -267,7 +267,7 @@ ksocknal_recv_iter(struct ksock_conn *conn)
>  	/* received something... */
>  	nob = rc;
>  
> -	conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
> +	conn->ksnc_peer->ksnp_last_alive = jiffies;
>  	conn->ksnc_rx_deadline =
>  		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>  	mb();		       /* order with setting rx_started */
> @@ -481,7 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>  		LASSERT(conn->ksnc_tx_scheduled);
>  		list_add_tail(&conn->ksnc_tx_list,
>  			      &ksocknal_data.ksnd_enomem_conns);
> -		if (!cfs_time_aftereq(cfs_time_add(cfs_time_current(),
> +		if (!cfs_time_aftereq(cfs_time_add(jiffies,
>  						   SOCKNAL_ENOMEM_RETRY),
>  				   ksocknal_data.ksnd_reaper_waketime))
>  			wake_up(&ksocknal_data.ksnd_reaper_waitq);
> @@ -612,7 +612,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
>  	conn = (typed) ? typed : fallback;
>  
>  	if (conn)
> -		conn->ksnc_tx_last_post = cfs_time_current();
> +		conn->ksnc_tx_last_post = jiffies;
>  
>  	return conn;
>  }
> @@ -680,7 +680,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
>  		conn->ksnc_tx_deadline =
>  			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>  		if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
> -			conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
> +			conn->ksnc_peer->ksnp_last_alive = jiffies;
>  		conn->ksnc_tx_bufnob = 0;
>  		mb(); /* order with adding to tx_queue */
>  	}
> @@ -728,7 +728,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
>  struct ksock_route *
>  ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
>  {
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	struct list_head *tmp;
>  	struct ksock_route *route;
>  
> @@ -1777,7 +1777,7 @@ ksocknal_connect(struct ksock_route *route)
>  	int retry_later = 0;
>  	int rc = 0;
>  
> -	deadline = cfs_time_add(cfs_time_current(),
> +	deadline = cfs_time_add(jiffies,
>  				*ksocknal_tunables.ksnd_timeout * HZ);
>  
>  	write_lock_bh(&ksocknal_data.ksnd_global_lock);
> @@ -1825,7 +1825,7 @@ ksocknal_connect(struct ksock_route *route)
>  
>  		write_unlock_bh(&ksocknal_data.ksnd_global_lock);
>  
> -		if (cfs_time_aftereq(cfs_time_current(), deadline)) {
> +		if (cfs_time_aftereq(jiffies, deadline)) {
>  			rc = -ETIMEDOUT;
>  			lnet_connect_console_error(rc, peer->ksnp_id.nid,
>  						   route->ksnr_ipaddr,
> @@ -1877,7 +1877,7 @@ ksocknal_connect(struct ksock_route *route)
>  			 */
>  			route->ksnr_retry_interval =
>  				*ksocknal_tunables.ksnd_min_reconnectms * HZ / 1000;
> -			route->ksnr_timeout = cfs_time_add(cfs_time_current(),
> +			route->ksnr_timeout = cfs_time_add(jiffies,
>  							   route->ksnr_retry_interval);
>  		}
>  
> @@ -1903,7 +1903,7 @@ ksocknal_connect(struct ksock_route *route)
>  		    (long)*ksocknal_tunables.ksnd_max_reconnectms * HZ / 1000);
>  
>  	LASSERT(route->ksnr_retry_interval);
> -	route->ksnr_timeout = cfs_time_add(cfs_time_current(),
> +	route->ksnr_timeout = cfs_time_add(jiffies,
>  					   route->ksnr_retry_interval);
>  
>  	if (!list_empty(&peer->ksnp_tx_queue) &&
> @@ -2050,7 +2050,7 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
>  	struct ksock_route *route;
>  	unsigned long now;
>  
> -	now = cfs_time_current();
> +	now = jiffies;
>  
>  	/* connd_routes can contain both pending and ordinary routes */
>  	list_for_each_entry(route, &ksocknal_data.ksnd_connd_routes,
> @@ -2228,7 +2228,7 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
>  		}
>  
>  		if (conn->ksnc_rx_started &&
> -		    cfs_time_aftereq(cfs_time_current(),
> +		    cfs_time_aftereq(jiffies,
>  				     conn->ksnc_rx_deadline)) {
>  			/* Timed out incomplete incoming message */
>  			ksocknal_conn_addref(conn);
> @@ -2244,7 +2244,7 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
>  
>  		if ((!list_empty(&conn->ksnc_tx_queue) ||
>  		     conn->ksnc_sock->sk->sk_wmem_queued) &&
> -		    cfs_time_aftereq(cfs_time_current(),
> +		    cfs_time_aftereq(jiffies,
>  				     conn->ksnc_tx_deadline)) {
>  			/*
>  			 * Timed out messages queued for sending or
> @@ -2272,7 +2272,7 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer)
>  	write_lock_bh(&ksocknal_data.ksnd_global_lock);
>  
>  	list_for_each_entry_safe(tx, tmp, &peer->ksnp_tx_queue, tx_list) {
> -		if (!cfs_time_aftereq(cfs_time_current(),
> +		if (!cfs_time_aftereq(jiffies,
>  				      tx->tx_deadline))
>  			break;
>  
> @@ -2301,12 +2301,12 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
>  		return 0;
>  
>  	if (*ksocknal_tunables.ksnd_keepalive <= 0 ||
> -	    time_before(cfs_time_current(),
> +	    time_before(jiffies,
>  			cfs_time_add(peer->ksnp_last_alive,
>  				     *ksocknal_tunables.ksnd_keepalive * HZ)))
>  		return 0;
>  
> -	if (time_before(cfs_time_current(), peer->ksnp_send_keepalive))
> +	if (time_before(jiffies, peer->ksnp_send_keepalive))
>  		return 0;
>  
>  	/*
> @@ -2400,7 +2400,7 @@ ksocknal_check_peer_timeouts(int idx)
>  			tx = list_entry(peer->ksnp_tx_queue.next,
>  					struct ksock_tx, tx_list);
>  
> -			if (cfs_time_aftereq(cfs_time_current(),
> +			if (cfs_time_aftereq(jiffies,
>  					     tx->tx_deadline)) {
>  				ksocknal_peer_addref(peer);
>  				read_unlock(&ksocknal_data.ksnd_global_lock);
> @@ -2418,7 +2418,7 @@ ksocknal_check_peer_timeouts(int idx)
>  		tx_stale = NULL;
>  		spin_lock(&peer->ksnp_lock);
>  		list_for_each_entry(tx, &peer->ksnp_zc_req_list, tx_zc_list) {
> -			if (!cfs_time_aftereq(cfs_time_current(),
> +			if (!cfs_time_aftereq(jiffies,
>  					      tx->tx_deadline))
>  				break;
>  			/* ignore the TX if connection is being closed */
> @@ -2444,7 +2444,7 @@ ksocknal_check_peer_timeouts(int idx)
>  
>  		CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n",
>  		       n, libcfs_nid2str(peer->ksnp_id.nid), tx_stale,
> -		       cfs_duration_sec(cfs_time_current() - deadline),
> +		       cfs_duration_sec(jiffies - deadline),
>  		       resid, conn->ksnc_sock->sk->sk_wmem_queued);
>  
>  		ksocknal_close_conn_and_siblings(conn, -ETIMEDOUT);
> @@ -2466,7 +2466,7 @@ ksocknal_reaper(void *arg)
>  	long timeout;
>  	int i;
>  	int peer_index = 0;
> -	unsigned long deadline = cfs_time_current();
> +	unsigned long deadline = jiffies;
>  
>  	INIT_LIST_HEAD(&enomem_conns);
>  	init_waitqueue_entry(&wait, current);
> @@ -2532,7 +2532,7 @@ ksocknal_reaper(void *arg)
>  
>  		/* careful with the jiffy wrap... */
>  		while ((timeout = cfs_time_sub(deadline,
> -					       cfs_time_current())) <= 0) {
> +					       jiffies)) <= 0) {
>  			const int n = 4;
>  			const int p = 1;
>  			int chunk = ksocknal_data.ksnd_peer_hash_size;
> @@ -2569,7 +2569,7 @@ ksocknal_reaper(void *arg)
>  			timeout = SOCKNAL_ENOMEM_RETRY;
>  		}
>  		ksocknal_data.ksnd_reaper_waketime =
> -			cfs_time_add(cfs_time_current(), timeout);
> +			cfs_time_add(jiffies, timeout);
>  
>  		set_current_state(TASK_INTERRUPTIBLE);
>  		add_wait_queue(&ksocknal_data.ksnd_reaper_waitq, &wait);
> diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> index 4affca750bc5..2aeae0331ee0 100644
> --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
> +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> @@ -431,7 +431,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  	if (cdls) {
>  		if (libcfs_console_ratelimit &&
>  		    cdls->cdls_next &&		/* not first time ever */
> -		    !cfs_time_after(cfs_time_current(), cdls->cdls_next)) {
> +		    !cfs_time_after(jiffies, cdls->cdls_next)) {
>  			/* skipping a console message */
>  			cdls->cdls_count++;
>  			if (tcd)
> @@ -439,7 +439,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  			return 1;
>  		}
>  
> -		if (cfs_time_after(cfs_time_current(),
> +		if (cfs_time_after(jiffies,
>  				   cdls->cdls_next + libcfs_console_max_delay +
>  				   10 * HZ)) {
>  			/* last timeout was a long time ago */
> @@ -454,7 +454,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  			cdls->cdls_delay = libcfs_console_max_delay;
>  
>  		/* ensure cdls_next is never zero after it's been seen */
> -		cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1;
> +		cdls->cdls_next = (jiffies + cdls->cdls_delay) | 1;
>  	}
>  
>  	if (tcd) {
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
> index ed43b3f4b114..289ed876bd81 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-move.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
> @@ -501,7 +501,7 @@ lnet_ni_query_locked(struct lnet_ni *ni, struct lnet_peer *lp)
>  	ni->ni_lnd->lnd_query(ni, lp->lp_nid, &last_alive);
>  	lnet_net_lock(lp->lp_cpt);
>  
> -	lp->lp_last_query = cfs_time_current();
> +	lp->lp_last_query = jiffies;
>  
>  	if (last_alive) /* NI has updated timestamp */
>  		lp->lp_last_alive = last_alive;
> @@ -545,7 +545,7 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
>  static int
>  lnet_peer_alive_locked(struct lnet_peer *lp)
>  {
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  
>  	if (!lnet_peer_aliveness_enabled(lp))
>  		return -ENODEV;
> diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
> index a63b7941d435..3928e9a74d6f 100644
> --- a/drivers/staging/lustre/lnet/lnet/net_fault.c
> +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
> @@ -306,7 +306,7 @@ drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
>  	/* match this rule, check drop rate now */
>  	spin_lock(&rule->dr_lock);
>  	if (rule->dr_drop_time) { /* time based drop */
> -		unsigned long now = cfs_time_current();
> +		unsigned long now = jiffies;
>  
>  		rule->dr_stat.fs_count++;
>  		drop = cfs_time_aftereq(now, rule->dr_drop_time);
> @@ -472,7 +472,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
>  	/* match this rule, check delay rate now */
>  	spin_lock(&rule->dl_lock);
>  	if (rule->dl_delay_time) { /* time based delay */
> -		unsigned long now = cfs_time_current();
> +		unsigned long now = jiffies;
>  
>  		rule->dl_stat.fs_count++;
>  		delay = cfs_time_aftereq(now, rule->dl_delay_time);
> @@ -562,7 +562,7 @@ delayed_msg_check(struct lnet_delay_rule *rule, bool all,
>  {
>  	struct lnet_msg *msg;
>  	struct lnet_msg *tmp;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  
>  	if (!all && rule->dl_msg_send > now)
>  		return;
> diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
> index 3d4caa609c83..58294149f7b2 100644
> --- a/drivers/staging/lustre/lnet/lnet/peer.c
> +++ b/drivers/staging/lustre/lnet/lnet/peer.c
> @@ -315,7 +315,7 @@ lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt)
>  	lp->lp_alive_count = 0;
>  	lp->lp_timestamp = 0;
>  	lp->lp_alive = !lnet_peers_start_down(); /* 1 bit!! */
> -	lp->lp_last_alive = cfs_time_current(); /* assumes alive */
> +	lp->lp_last_alive = jiffies; /* assumes alive */
>  	lp->lp_last_query = 0; /* haven't asked NI yet */
>  	lp->lp_ping_timestamp = 0;
>  	lp->lp_ping_feats = LNET_PING_FEAT_INVAL;
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index a3c3f4959f46..ac9b392a0afa 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -765,7 +765,7 @@ lnet_router_checker_event(struct lnet_event *event)
>  	 * we ping alive routers to try to detect router death before
>  	 * apps get burned).
>  	 */
> -	lnet_notify_locked(lp, 1, !event->status, cfs_time_current());
> +	lnet_notify_locked(lp, 1, !event->status, jiffies);
>  
>  	/*
>  	 * The router checker will wake up very shortly and do the
> @@ -976,7 +976,7 @@ static void
>  lnet_ping_router_locked(struct lnet_peer *rtr)
>  {
>  	struct lnet_rc_data *rcd = NULL;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	int secs;
>  
>  	lnet_peer_addref_locked(rtr);
> @@ -1730,7 +1730,7 @@ int
>  lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
>  {
>  	struct lnet_peer *lp = NULL;
> -	unsigned long now = cfs_time_current();
> +	unsigned long now = jiffies;
>  	int cpt = lnet_cpt_of_nid(nid);
>  
>  	LASSERT(!in_interrupt());
> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
> index 1a71ffebc889..315d067540c0 100644
> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c
> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
> @@ -324,7 +324,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
>  
>  		if (peer) {
>  			lnet_nid_t nid = peer->lp_nid;
> -			unsigned long now = cfs_time_current();
> +			unsigned long now = jiffies;
>  			unsigned long deadline = peer->lp_ping_deadline;
>  			int nrefs = peer->lp_refcount;
>  			int nrtrrefs = peer->lp_rtr_refcount;
> @@ -509,7 +509,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
>  				aliveness = peer->lp_alive ? "up" : "down";
>  
>  			if (lnet_peer_aliveness_enabled(peer)) {
> -				unsigned long now = cfs_time_current();
> +				unsigned long now = jiffies;
>  				long delta;
>  
>  				delta = cfs_time_sub(now, peer->lp_last_alive);
> diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
> index 6dcc966b293b..68e06e06857d 100644
> --- a/drivers/staging/lustre/lnet/selftest/conrpc.c
> +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
> @@ -75,7 +75,7 @@ lstcon_rpc_done(struct srpc_client_rpc *rpc)
>  		/* not aborted */
>  		LASSERT(!crpc->crp_status);
>  
> -		crpc->crp_stamp = cfs_time_current();
> +		crpc->crp_stamp = jiffies;
>  		crpc->crp_status = rpc->crpc_status;
>  	}
>  
> @@ -297,14 +297,14 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
>  		if (!crpc->crp_posted || /* not posted */
>  		    crpc->crp_stamp) {	 /* rpc done or aborted already */
>  			if (!crpc->crp_stamp) {
> -				crpc->crp_stamp = cfs_time_current();
> +				crpc->crp_stamp = jiffies;
>  				crpc->crp_status = -EINTR;
>  			}
>  			spin_unlock(&rpc->crpc_lock);
>  			continue;
>  		}
>  
> -		crpc->crp_stamp = cfs_time_current();
> +		crpc->crp_stamp = jiffies;
>  		crpc->crp_status = error;
>  
>  		spin_unlock(&rpc->crpc_lock);
> diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
> index 1acd5cb324b1..1889f1e86473 100644
> --- a/drivers/staging/lustre/lnet/selftest/console.c
> +++ b/drivers/staging/lustre/lnet/selftest/console.c
> @@ -98,7 +98,7 @@ lstcon_node_find(struct lnet_process_id id, struct lstcon_node **ndpp,
>  
>  	ndl->ndl_node->nd_ref = 1;
>  	ndl->ndl_node->nd_id = id;
> -	ndl->ndl_node->nd_stamp = cfs_time_current();
> +	ndl->ndl_node->nd_stamp = jiffies;
>  	ndl->ndl_node->nd_state = LST_NODE_UNKNOWN;
>  	ndl->ndl_node->nd_timeout = 0;
>  	memset(&ndl->ndl_node->nd_ping, 0, sizeof(struct lstcon_rpc));
> @@ -1701,7 +1701,7 @@ lstcon_new_session_id(struct lst_sid *sid)
>  
>  	LNetGetId(1, &id);
>  	sid->ses_nid = id.nid;
> -	sid->ses_stamp = cfs_time_current();
> +	sid->ses_stamp = jiffies;
>  }
>  
>  int
> diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
> index 0ca1e3a780ca..045eecd23e0a 100644
> --- a/drivers/staging/lustre/lnet/selftest/framework.c
> +++ b/drivers/staging/lustre/lnet/selftest/framework.c
> @@ -272,7 +272,7 @@ sfw_init_session(struct sfw_session *sn, struct lst_sid sid,
>  	sn->sn_id = sid;
>  	sn->sn_features = features;
>  	sn->sn_timeout = session_timeout;
> -	sn->sn_started = cfs_time_current();
> +	sn->sn_started = jiffies;
>  
>  	timer->stt_data = sn;
>  	timer->stt_func = sfw_session_expired;
> diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
> index d35ae0cda8d2..f4824d8ec741 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_net.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_net.h
> @@ -2255,7 +2255,7 @@ static inline int ptlrpc_send_limit_expired(struct ptlrpc_request *req)
>  	if (req->rq_delay_limit != 0 &&
>  	    time_before(cfs_time_add(req->rq_queued_time,
>  				     req->rq_delay_limit * HZ),
> -			cfs_time_current())) {
> +			jiffies)) {
>  		return 1;
>  	}
>  	return 0;
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> index f24dd74ffa09..7cfc3c8d100c 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -913,7 +913,7 @@ static inline int obd_destroy_export(struct obd_export *exp)
>  /*
>   * @max_age is the oldest time in jiffies that we accept using a cached data.
>   * If the cache is older than @max_age we will get a new value from the
> - * target.  Use a value of "cfs_time_current() + HZ" to guarantee freshness.
> + * target.  Use a value of "jiffies + HZ" to guarantee freshness.
>   */
>  static inline int obd_statfs_async(struct obd_export *exp,
>  				   struct obd_info *oinfo,
> @@ -975,7 +975,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp,
>  /*
>   * @max_age is the oldest time in jiffies that we accept using a cached data.
>   * If the cache is older than @max_age we will get a new value from the
> - * target.  Use a value of "cfs_time_current() + HZ" to guarantee freshness.
> + * target.  Use a value of "jiffies + HZ" to guarantee freshness.
>   */
>  static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
>  			     struct obd_statfs *osfs, __u64 max_age,
> @@ -997,7 +997,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
>  		if (rc == 0) {
>  			spin_lock(&obd->obd_osfs_lock);
>  			memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
> -			obd->obd_osfs_age = cfs_time_current_64();
> +			obd->obd_osfs_age = get_jiffies_64();
>  			spin_unlock(&obd->obd_osfs_lock);
>  		}
>  	} else {
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> index 614caa4a9b0e..22c49cc593e3 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
> @@ -243,7 +243,7 @@ static void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock)
>  {
>  	struct ldlm_namespace *ns = ldlm_lock_to_ns(lock);
>  
> -	lock->l_last_used = cfs_time_current();
> +	lock->l_last_used = jiffies;
>  	LASSERT(list_empty(&lock->l_lru));
>  	LASSERT(lock->l_resource->lr_type != LDLM_FLOCK);
>  	list_add_tail(&lock->l_lru, &ns->ns_unused_list);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> index c772c68e5a49..ab4dd15c8dd4 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> @@ -325,7 +325,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
>  	lock_res_and_lock(lock);
>  	if (lock->l_granted_mode == LCK_PW &&
>  	    !lock->l_readers && !lock->l_writers &&
> -	    cfs_time_after(cfs_time_current(),
> +	    cfs_time_after(jiffies,
>  			   cfs_time_add(lock->l_last_used,
>  					10 * HZ))) {
>  		unlock_res_and_lock(lock);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index 8e79f5e073ff..0e1b21c1f06d 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -116,7 +116,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
>  			   (s64)lock->l_last_activity,
>  			   (s64)(ktime_get_real_seconds() -
>  				 lock->l_last_activity));
> -		if (cfs_time_after(cfs_time_current(), next_dump)) {
> +		if (cfs_time_after(jiffies, next_dump)) {
>  			last_dump = next_dump;
>  			next_dump = cfs_time_shift(300);
>  			ldlm_namespace_dump(D_DLMTRACE,
> @@ -1161,7 +1161,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
>  						    int unused, int added,
>  						    int count)
>  {
> -	unsigned long cur = cfs_time_current();
> +	unsigned long cur = jiffies;
>  	struct ldlm_pool *pl = &ns->ns_pool;
>  	__u64 slv, lvf, lv;
>  	unsigned long la;
> @@ -1176,7 +1176,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
>  	 * Despite of the LV, It doesn't make sense to keep the lock which
>  	 * is unused for ns_max_age time.
>  	 */
> -	if (cfs_time_after(cfs_time_current(),
> +	if (cfs_time_after(jiffies,
>  			   cfs_time_add(lock->l_last_used, ns->ns_max_age)))
>  		return LDLM_POLICY_CANCEL_LOCK;
>  
> @@ -1233,7 +1233,7 @@ static enum ldlm_policy_res ldlm_cancel_aged_policy(struct ldlm_namespace *ns,
>  						    int count)
>  {
>  	if ((added >= count) &&
> -	    time_before(cfs_time_current(),
> +	    time_before(jiffies,
>  			cfs_time_add(lock->l_last_used, ns->ns_max_age)))
>  		return LDLM_POLICY_KEEP_LOCK;
>  
> @@ -1380,7 +1380,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns,
>  				continue;
>  
>  			last_use = lock->l_last_used;
> -			if (last_use == cfs_time_current())
> +			if (last_use == jiffies)
>  				continue;
>  
>  			/* Somebody is already doing CANCEL. No need for this
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> index 8841a1bb2c0a..ccd0c082e39b 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> @@ -1316,7 +1316,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
>  	CDEBUG(level, "--- Namespace: %s (rc: %d, side: client)\n",
>  	       ldlm_ns_name(ns), atomic_read(&ns->ns_bref));
>  
> -	if (time_before(cfs_time_current(), ns->ns_next_dump))
> +	if (time_before(jiffies, ns->ns_next_dump))
>  		return;
>  
>  	cfs_hash_for_each_nolock(ns->ns_rs_hash,
> diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
> index d46bcf71b273..6504850e3689 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_internal.h
> +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
> @@ -1110,7 +1110,7 @@ static inline int ll_glimpse_size(struct inode *inode)
>  
>  	down_read(&lli->lli_glimpse_sem);
>  	rc = cl_glimpse_size(inode);
> -	lli->lli_glimpse_time = cfs_time_current();
> +	lli->lli_glimpse_time = jiffies;
>  	up_read(&lli->lli_glimpse_sem);
>  	return rc;
>  }
> diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
> index 155ce3cf6f60..6f996acf6aa8 100644
> --- a/drivers/staging/lustre/lustre/llite/statahead.c
> +++ b/drivers/staging/lustre/lustre/llite/statahead.c
> @@ -535,7 +535,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
>  
>  	cl_agl(inode);
>  	lli->lli_agl_index = 0;
> -	lli->lli_glimpse_time = cfs_time_current();
> +	lli->lli_glimpse_time = jiffies;
>  	up_write(&lli->lli_glimpse_sem);
>  
>  	CDEBUG(D_READA, "Handled (init) async glimpse: inode= "
> diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
> index 051450d67524..41fc023cc381 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_request.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_request.c
> @@ -160,7 +160,7 @@ static int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,
>  
>  		spin_lock(&obd->obd_osfs_lock);
>  		memcpy(&obd->obd_osfs, osfs, sizeof(*osfs));
> -		obd->obd_osfs_age = cfs_time_current_64();
> +		obd->obd_osfs_age = get_jiffies_64();
>  		spin_unlock(&obd->obd_osfs_lock);
>  		return 0;
>  	}
> @@ -277,7 +277,7 @@ static int cb_statfs_update(void *cookie, int rc)
>  	spin_lock(&tgtobd->obd_osfs_lock);
>  	memcpy(&tgtobd->obd_osfs, lov_sfs, sizeof(*lov_sfs));
>  	if ((oinfo->oi_flags & OBD_STATFS_FROM_CACHE) == 0)
> -		tgtobd->obd_osfs_age = cfs_time_current_64();
> +		tgtobd->obd_osfs_age = get_jiffies_64();
>  	spin_unlock(&tgtobd->obd_osfs_lock);
>  
>  out_update:
> diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
> index 459503727ce3..ba4a4bf3b0f1 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_cache.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
> @@ -1290,7 +1290,7 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap,
>  
>  	result = cl_page_make_ready(env, page, CRT_WRITE);
>  	if (result == 0)
> -		opg->ops_submit_time = cfs_time_current();
> +		opg->ops_submit_time = jiffies;
>  	return result;
>  }
>  
> diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
> index 9582d5a642e2..c5dc894a4c1b 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_object.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_object.c
> @@ -300,7 +300,7 @@ static int osc_object_fiemap(const struct lu_env *env, struct cl_object *obj,
>  
>  void osc_object_set_contended(struct osc_object *obj)
>  {
> -	obj->oo_contention_time = cfs_time_current();
> +	obj->oo_contention_time = jiffies;
>  	/* mb(); */
>  	obj->oo_contended = 1;
>  }
> @@ -314,7 +314,7 @@ int osc_object_is_contended(struct osc_object *obj)
>  {
>  	struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
>  	int osc_contention_time = dev->od_contention_time;
> -	unsigned long cur_time = cfs_time_current();
> +	unsigned long cur_time = jiffies;
>  	unsigned long retry_time;
>  
>  	if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
> diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
> index 01a930dbbf64..20c553ef3a5e 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_page.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_page.c
> @@ -125,7 +125,7 @@ static inline unsigned long osc_submit_duration(struct osc_page *opg)
>  	if (opg->ops_submit_time == 0)
>  		return 0;
>  
> -	return (cfs_time_current() - opg->ops_submit_time);
> +	return (jiffies - opg->ops_submit_time);
>  }
>  
>  static int osc_page_print(const struct lu_env *env,
> @@ -312,7 +312,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
>  		oap->oap_cmd |= OBD_BRW_NOQUOTA;
>  	}
>  
> -	opg->ops_submit_time = cfs_time_current();
> +	opg->ops_submit_time = jiffies;
>  	osc_page_transfer_get(opg, "transfer\0imm");
>  	osc_page_transfer_add(env, opg, crt);
>  }
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 1c2bbbf5d864..9966fc7af789 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -741,7 +741,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
>  
>  static int osc_should_shrink_grant(struct client_obd *client)
>  {
> -	unsigned long time = cfs_time_current();
> +	unsigned long time = jiffies;
>  	unsigned long next_shrink = client->cl_next_shrink_grant;
>  
>  	if ((client->cl_import->imp_connect_data.ocd_connect_flags &
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
> index ca096fadb9c0..eeb281266413 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/client.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
> @@ -1050,7 +1050,7 @@ void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
>  	list_add_tail(&req->rq_set_chain, &set->set_requests);
>  	req->rq_set = set;
>  	atomic_inc(&set->set_remaining);
> -	req->rq_queued_time = cfs_time_current();
> +	req->rq_queued_time = jiffies;
>  
>  	if (req->rq_reqmsg)
>  		lustre_msg_set_jobid(req->rq_reqmsg, NULL);
> @@ -1081,7 +1081,7 @@ void ptlrpc_set_add_new_req(struct ptlrpcd_ctl *pc,
>  	spin_lock(&set->set_new_req_lock);
>  	/* The set takes over the caller's request reference.  */
>  	req->rq_set = set;
> -	req->rq_queued_time = cfs_time_current();
> +	req->rq_queued_time = jiffies;
>  	list_add_tail(&req->rq_set_chain, &set->set_new_requests);
>  	count = atomic_inc_return(&set->set_new_count);
>  	spin_unlock(&set->set_new_req_lock);
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index a2c4fc3488b1..4a9d1f189d01 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -508,7 +508,7 @@ static int import_select_connection(struct obd_import *imp)
>  		       imp->imp_obd->obd_name, at_get(at));
>  	}
>  
> -	imp_conn->oic_last_attempt = cfs_time_current_64();
> +	imp_conn->oic_last_attempt = get_jiffies_64();
>  
>  	/* switch connection, don't mind if it's same as the current one */
>  	ptlrpc_connection_put(imp->imp_connection);
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> index 0775b7a048bb..57c7db47e249 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> @@ -142,7 +142,7 @@ static long pinger_check_timeout(unsigned long time)
>  	mutex_unlock(&pinger_mutex);
>  
>  	return cfs_time_sub(cfs_time_add(time, timeout * HZ),
> -					 cfs_time_current());
> +					 jiffies);
>  }
>  
>  static bool ir_up;
> @@ -223,7 +223,7 @@ static DECLARE_DELAYED_WORK(ping_work, ptlrpc_pinger_main);
>  
>  static void ptlrpc_pinger_main(struct work_struct *ws)
>  {
> -	unsigned long this_ping = cfs_time_current();
> +	unsigned long this_ping = jiffies;
>  	long time_to_next_wake;
>  	struct timeout_item *item;
>  	struct obd_import *imp;
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
> index f37364e00dfe..fc29efbd9914 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
> @@ -336,7 +336,7 @@ static void ptlrpc_at_timer(struct timer_list *t)
>  	svcpt = from_timer(svcpt, t, scp_at_timer);
>  
>  	svcpt->scp_at_check = 1;
> -	svcpt->scp_at_checktime = cfs_time_current();
> +	svcpt->scp_at_checktime = jiffies;
>  	wake_up(&svcpt->scp_waitq);
>  }
>  
> @@ -1153,7 +1153,7 @@ static void ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt)
>  		spin_unlock(&svcpt->scp_at_lock);
>  		return;
>  	}
> -	delay = cfs_time_sub(cfs_time_current(), svcpt->scp_at_checktime);
> +	delay = cfs_time_sub(jiffies, svcpt->scp_at_checktime);
>  	svcpt->scp_at_check = 0;
>  
>  	if (array->paa_count == 0) {
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 12/17] staging: lustre: libcfs: discard cfs_time_after()
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 19:01     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:01 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> cfs_time_after() behaves exactly like time_after()
> similarly cfs_time_aftereq() matches time_after_eq()
> 
> so discard the cfs versions.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/libcfs_time.h      |   14 ---------
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    4 +--
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |    6 ++--
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    2 +
>  .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   32 ++++++++++----------
>  drivers/staging/lustre/lnet/libcfs/tracefile.c     |    8 +++--
>  drivers/staging/lustre/lnet/lnet/lib-move.c        |    4 +--
>  drivers/staging/lustre/lnet/lnet/net_fault.c       |    8 +++--
>  drivers/staging/lustre/lnet/lnet/router.c          |    6 ++--
>  drivers/staging/lustre/lnet/selftest/conrpc.c      |    4 +--
>  drivers/staging/lustre/lnet/selftest/timer.c       |    2 +
>  drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    4 +--
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    4 +--
>  drivers/staging/lustre/lustre/osc/osc_object.c     |    2 +
>  drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +
>  drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    6 ++--
>  16 files changed, 47 insertions(+), 61 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> index 0ebbde4ec8e8..172a8872e3f3 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> @@ -36,20 +36,6 @@
>  
>  #ifndef __LIBCFS_TIME_H__
>  #define __LIBCFS_TIME_H__
> -/*
> - * generic time manipulation functions.
> - */
> -
> -static inline int cfs_time_after(unsigned long t1, unsigned long t2)
> -{
> -	return time_before(t2, t1);
> -}
> -
> -static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
> -{
> -	return time_before_eq(t2, t1);
> -}
> -
>  /*
>   * return valid time-out based on user supplied one. Currently we only check
>   * that time-out is not shorted than allowed.
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index 276bf486f64b..d0ce37d72571 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -1522,7 +1522,7 @@ static int kiblnd_fmr_pool_is_idle(struct kib_fmr_pool *fpo, unsigned long now)
>  		return 0;
>  	if (fpo->fpo_failed)
>  		return 1;
> -	return cfs_time_aftereq(now, fpo->fpo_deadline);
> +	return time_after_eq(now, fpo->fpo_deadline);
>  }
>  
>  static int
> @@ -1850,7 +1850,7 @@ static int kiblnd_pool_is_idle(struct kib_pool *pool, unsigned long now)
>  		return 0;
>  	if (pool->po_failed)
>  		return 1;
> -	return cfs_time_aftereq(now, pool->po_deadline);
> +	return time_after_eq(now, pool->po_deadline);
>  }
>  
>  void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> index b18911d09e9a..ca6e09de0872 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> @@ -754,9 +754,9 @@ static inline int
>  kiblnd_send_keepalive(struct kib_conn *conn)
>  {
>  	return (*kiblnd_tunables.kib_keepalive > 0) &&
> -		cfs_time_after(jiffies, conn->ibc_last_send +
> -			       msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
> -						MSEC_PER_SEC));
> +		time_after(jiffies, conn->ibc_last_send +
> +			   msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
> +					    MSEC_PER_SEC));
>  }
>  
>  static inline int
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> index f9761d8f2e3e..563ff5c972bf 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> @@ -3141,7 +3141,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs)
>  			LASSERT(tx->tx_waiting || tx->tx_sending);
>  		}
>  
> -		if (cfs_time_aftereq(jiffies, tx->tx_deadline)) {
> +		if (time_after_eq(jiffies, tx->tx_deadline)) {
>  			CERROR("Timed out tx: %s, %lu seconds\n",
>  			       kiblnd_queue2str(conn, txs),
>  			       cfs_duration_sec(jiffies - tx->tx_deadline));
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index 1ace54c9b133..8ead1e02e854 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -481,7 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>  		LASSERT(conn->ksnc_tx_scheduled);
>  		list_add_tail(&conn->ksnc_tx_list,
>  			      &ksocknal_data.ksnd_enomem_conns);
> -		if (!cfs_time_aftereq(jiffies + SOCKNAL_ENOMEM_RETRY,
> +		if (!time_after_eq(jiffies + SOCKNAL_ENOMEM_RETRY,
>  				   ksocknal_data.ksnd_reaper_waketime))
>  			wake_up(&ksocknal_data.ksnd_reaper_waitq);
>  
> @@ -590,7 +590,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
>  		case SOCKNAL_MATCH_YES: /* typed connection */
>  			if (!typed || tnob > nob ||
>  			    (tnob == nob && *ksocknal_tunables.ksnd_round_robin &&
> -			     cfs_time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
> +			     time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
>  				typed = c;
>  				tnob  = nob;
>  			}
> @@ -599,7 +599,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
>  		case SOCKNAL_MATCH_MAY: /* fallback connection */
>  			if (!fallback || fnob > nob ||
>  			    (fnob == nob && *ksocknal_tunables.ksnd_round_robin &&
> -			     cfs_time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
> +			     time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
>  				fallback = c;
>  				fnob = nob;
>  			}
> @@ -745,7 +745,7 @@ ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
>  			continue;
>  
>  		if (!(!route->ksnr_retry_interval || /* first attempt */
> -		      cfs_time_aftereq(now, route->ksnr_timeout))) {
> +		      time_after_eq(now, route->ksnr_timeout))) {
>  			CDEBUG(D_NET,
>  			       "Too soon to retry route %pI4h (cnted %d, interval %ld, %ld secs later)\n",
>  			       &route->ksnr_ipaddr,
> @@ -1823,7 +1823,7 @@ ksocknal_connect(struct ksock_route *route)
>  
>  		write_unlock_bh(&ksocknal_data.ksnd_global_lock);
>  
> -		if (cfs_time_aftereq(jiffies, deadline)) {
> +		if (time_after_eq(jiffies, deadline)) {
>  			rc = -ETIMEDOUT;
>  			lnet_connect_console_error(rc, peer->ksnp_id.nid,
>  						   route->ksnr_ipaddr,
> @@ -2052,7 +2052,7 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
>  	list_for_each_entry(route, &ksocknal_data.ksnd_connd_routes,
>  			    ksnr_connd_list) {
>  		if (!route->ksnr_retry_interval ||
> -		    cfs_time_aftereq(now, route->ksnr_timeout))
> +		    time_after_eq(now, route->ksnr_timeout))
>  			return route;
>  
>  		if (*timeout_p == MAX_SCHEDULE_TIMEOUT ||
> @@ -2224,8 +2224,8 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
>  		}
>  
>  		if (conn->ksnc_rx_started &&
> -		    cfs_time_aftereq(jiffies,
> -				     conn->ksnc_rx_deadline)) {
> +		    time_after_eq(jiffies,
> +				  conn->ksnc_rx_deadline)) {
>  			/* Timed out incomplete incoming message */
>  			ksocknal_conn_addref(conn);
>  			CNETERR("Timeout receiving from %s (%pI4h:%d), state %d wanted %zd left %d\n",
> @@ -2240,8 +2240,8 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
>  
>  		if ((!list_empty(&conn->ksnc_tx_queue) ||
>  		     conn->ksnc_sock->sk->sk_wmem_queued) &&
> -		    cfs_time_aftereq(jiffies,
> -				     conn->ksnc_tx_deadline)) {
> +		    time_after_eq(jiffies,
> +				  conn->ksnc_tx_deadline)) {
>  			/*
>  			 * Timed out messages queued for sending or
>  			 * buffered in the socket's send buffer
> @@ -2268,8 +2268,8 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer)
>  	write_lock_bh(&ksocknal_data.ksnd_global_lock);
>  
>  	list_for_each_entry_safe(tx, tmp, &peer->ksnp_tx_queue, tx_list) {
> -		if (!cfs_time_aftereq(jiffies,
> -				      tx->tx_deadline))
> +		if (!time_after_eq(jiffies,
> +				   tx->tx_deadline))
>  			break;
>  
>  		list_del(&tx->tx_list);
> @@ -2395,8 +2395,8 @@ ksocknal_check_peer_timeouts(int idx)
>  			tx = list_entry(peer->ksnp_tx_queue.next,
>  					struct ksock_tx, tx_list);
>  
> -			if (cfs_time_aftereq(jiffies,
> -					     tx->tx_deadline)) {
> +			if (time_after_eq(jiffies,
> +					  tx->tx_deadline)) {
>  				ksocknal_peer_addref(peer);
>  				read_unlock(&ksocknal_data.ksnd_global_lock);
>  
> @@ -2413,8 +2413,8 @@ ksocknal_check_peer_timeouts(int idx)
>  		tx_stale = NULL;
>  		spin_lock(&peer->ksnp_lock);
>  		list_for_each_entry(tx, &peer->ksnp_zc_req_list, tx_zc_list) {
> -			if (!cfs_time_aftereq(jiffies,
> -					      tx->tx_deadline))
> +			if (!time_after_eq(jiffies,
> +					   tx->tx_deadline))
>  				break;
>  			/* ignore the TX if connection is being closed */
>  			if (tx->tx_conn->ksnc_closing)
> diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> index 2aeae0331ee0..129430e74d00 100644
> --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
> +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> @@ -431,7 +431,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  	if (cdls) {
>  		if (libcfs_console_ratelimit &&
>  		    cdls->cdls_next &&		/* not first time ever */
> -		    !cfs_time_after(jiffies, cdls->cdls_next)) {
> +		    !time_after(jiffies, cdls->cdls_next)) {
>  			/* skipping a console message */
>  			cdls->cdls_count++;
>  			if (tcd)
> @@ -439,9 +439,9 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  			return 1;
>  		}
>  
> -		if (cfs_time_after(jiffies,
> -				   cdls->cdls_next + libcfs_console_max_delay +
> -				   10 * HZ)) {
> +		if (time_after(jiffies,
> +			       cdls->cdls_next + libcfs_console_max_delay +
> +			       10 * HZ)) {
>  			/* last timeout was a long time ago */
>  			cdls->cdls_delay /= libcfs_console_backoff * 4;
>  		} else {
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
> index 5574d2148c9d..60464135161b 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-move.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
> @@ -520,11 +520,11 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
>  	 * ignore the initial assumed death (see lnet_peers_start_down()).
>  	 */
>  	if (!lp->lp_alive && lp->lp_alive_count > 0 &&
> -	    cfs_time_aftereq(lp->lp_timestamp, lp->lp_last_alive))
> +	    time_after_eq(lp->lp_timestamp, lp->lp_last_alive))
>  		return 0;
>  
>  	deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout * HZ;
> -	alive = cfs_time_after(deadline, now);
> +	alive = time_after(deadline, now);
>  
>  	/* Update obsolete lp_alive except for routers assumed to be dead
>  	 * initially, because router checker would update aliveness in this
> diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
> index 05d7b754815a..0066394b0bb0 100644
> --- a/drivers/staging/lustre/lnet/lnet/net_fault.c
> +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
> @@ -309,9 +309,9 @@ drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
>  		unsigned long now = jiffies;
>  
>  		rule->dr_stat.fs_count++;
> -		drop = cfs_time_aftereq(now, rule->dr_drop_time);
> +		drop = time_after_eq(now, rule->dr_drop_time);
>  		if (drop) {
> -			if (cfs_time_after(now, rule->dr_time_base))
> +			if (time_after(now, rule->dr_time_base))
>  				rule->dr_time_base = now;
>  
>  			rule->dr_drop_time = rule->dr_time_base +
> @@ -475,9 +475,9 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
>  		unsigned long now = jiffies;
>  
>  		rule->dl_stat.fs_count++;
> -		delay = cfs_time_aftereq(now, rule->dl_delay_time);
> +		delay = time_after_eq(now, rule->dl_delay_time);
>  		if (delay) {
> -			if (cfs_time_after(now, rule->dl_time_base))
> +			if (time_after(now, rule->dl_time_base))
>  				rule->dl_time_base = now;
>  
>  			rule->dl_delay_time = rule->dl_time_base +
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index c72d4f4454ec..8baf35d56ca7 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -982,7 +982,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
>  	lnet_peer_addref_locked(rtr);
>  
>  	if (rtr->lp_ping_deadline && /* ping timed out? */
> -	    cfs_time_after(now, rtr->lp_ping_deadline))
> +	    time_after(now, rtr->lp_ping_deadline))
>  		lnet_notify_locked(rtr, 1, 0, now);
>  
>  	/* Run any outstanding notifications */
> @@ -1010,7 +1010,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
>  	       rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
>  
>  	if (secs && !rtr->lp_ping_notsent &&
> -	    cfs_time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
> +	    time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
>  		int rc;
>  		struct lnet_process_id id;
>  		struct lnet_handle_md mdh;
> @@ -1748,7 +1748,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
>  	}
>  
>  	/* can't do predictions... */
> -	if (cfs_time_after(when, now)) {
> +	if (time_after(when, now)) {
>  		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
>  		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
>  		      libcfs_nid2str(nid), alive ? "up" : "down",
> diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
> index ea4944b9108b..8c237758c3eb 100644
> --- a/drivers/staging/lustre/lnet/selftest/conrpc.c
> +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
> @@ -315,7 +315,7 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
>  			continue;
>  
>  		nd = crpc->crp_node;
> -		if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
> +		if (time_after(nd->nd_stamp, crpc->crp_stamp))
>  			continue;
>  
>  		nd->nd_stamp = crpc->crp_stamp;
> @@ -404,7 +404,7 @@ lstcon_rpc_get_reply(struct lstcon_rpc *crpc, struct srpc_msg **msgpp)
>  		crpc->crp_unpacked = 1;
>  	}
>  
> -	if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
> +	if (time_after(nd->nd_stamp, crpc->crp_stamp))
>  		return 0;
>  
>  	nd->nd_stamp = crpc->crp_stamp;
> diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
> index 1f9d5487e2f5..582f252b3e12 100644
> --- a/drivers/staging/lustre/lnet/selftest/timer.c
> +++ b/drivers/staging/lustre/lnet/selftest/timer.c
> @@ -155,7 +155,7 @@ stt_check_timers(unsigned long *last)
>  
>  	spin_lock(&stt_data.stt_lock);
>  
> -	while (cfs_time_aftereq(this_slot, *last)) {
> +	while (time_after_eq(this_slot, *last)) {
>  		expired += stt_expire_list(STTIMER_SLOT(this_slot), now);
>  		this_slot = this_slot - STTIMER_SLOTTIME;
>  	}
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> index 150e78c9eb68..942d34f7a44c 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> @@ -325,8 +325,8 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
>  	lock_res_and_lock(lock);
>  	if (lock->l_granted_mode == LCK_PW &&
>  	    !lock->l_readers && !lock->l_writers &&
> -	    cfs_time_after(jiffies,
> -			   lock->l_last_used + 10 * HZ)) {
> +	    time_after(jiffies,
> +		       lock->l_last_used + 10 * HZ)) {
>  		unlock_res_and_lock(lock);
>  		if (ldlm_bl_to_thread_lock(ns, NULL, lock))
>  			ldlm_handle_bl_callback(ns, NULL, lock);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index 647e85b16c02..187095022fb1 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -116,7 +116,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
>  			   (s64)lock->l_last_activity,
>  			   (s64)(ktime_get_real_seconds() -
>  				 lock->l_last_activity));
> -		if (cfs_time_after(jiffies, next_dump)) {
> +		if (time_after(jiffies, next_dump)) {
>  			last_dump = next_dump;
>  			next_dump = jiffies + 300 * HZ;
>  			ldlm_namespace_dump(D_DLMTRACE,
> @@ -1176,7 +1176,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
>  	 * Despite of the LV, It doesn't make sense to keep the lock which
>  	 * is unused for ns_max_age time.
>  	 */
> -	if (cfs_time_after(jiffies, lock->l_last_used + ns->ns_max_age))
> +	if (time_after(jiffies, lock->l_last_used + ns->ns_max_age))
>  		return LDLM_POLICY_CANCEL_LOCK;
>  
>  	slv = ldlm_pool_get_slv(pl);
> diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
> index 154d1721636e..84240181c7ea 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_object.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_object.c
> @@ -328,7 +328,7 @@ int osc_object_is_contended(struct osc_object *obj)
>  	 * ll_file_is_contended.
>  	 */
>  	retry_time = obj->oo_contention_time + osc_contention_time * HZ;
> -	if (cfs_time_after(cur_time, retry_time)) {
> +	if (time_after(cur_time, retry_time)) {
>  		osc_object_clear_contended(obj);
>  		return 0;
>  	}
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 04d801f11ace..0038e555e905 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -748,7 +748,7 @@ static int osc_should_shrink_grant(struct client_obd *client)
>  	     OBD_CONNECT_GRANT_SHRINK) == 0)
>  		return 0;
>  
> -	if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) {
> +	if (time_after_eq(time, next_shrink - 5 * CFS_TICK)) {
>  		/* Get the current RPC size directly, instead of going via:
>  		 * cli_brw_size(obd->u.cli.cl_import->imp_obd->obd_self_export)
>  		 * Keep comment here so that it can be found by searching.
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> index 7057b4447035..3f17c673d1b8 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> @@ -180,7 +180,7 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp,
>  
>  	imp->imp_force_verify = 0;
>  
> -	if (cfs_time_aftereq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
> +	if (time_after_eq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
>  	    !force) {
>  		spin_unlock(&imp->imp_lock);
>  		return;
> @@ -236,8 +236,8 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
>  			ptlrpc_pinger_process_import(imp, this_ping);
>  			/* obd_timeout might have changed */
>  			if (imp->imp_pingable && imp->imp_next_ping &&
> -			    cfs_time_after(imp->imp_next_ping,
> -					   this_ping + PING_INTERVAL * HZ))
> +			    time_after(imp->imp_next_ping,
> +				       this_ping + PING_INTERVAL * HZ))
>  				ptlrpc_update_next_ping(imp, 0);
>  		}
>  		mutex_unlock(&pinger_mutex);
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 12/17] staging: lustre: libcfs: discard cfs_time_after()
@ 2018-03-30 19:01     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:01 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> cfs_time_after() behaves exactly like time_after()
> similarly cfs_time_aftereq() matches time_after_eq()
> 
> so discard the cfs versions.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/libcfs_time.h      |   14 ---------
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    4 +--
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h    |    6 ++--
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    2 +
>  .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   32 ++++++++++----------
>  drivers/staging/lustre/lnet/libcfs/tracefile.c     |    8 +++--
>  drivers/staging/lustre/lnet/lnet/lib-move.c        |    4 +--
>  drivers/staging/lustre/lnet/lnet/net_fault.c       |    8 +++--
>  drivers/staging/lustre/lnet/lnet/router.c          |    6 ++--
>  drivers/staging/lustre/lnet/selftest/conrpc.c      |    4 +--
>  drivers/staging/lustre/lnet/selftest/timer.c       |    2 +
>  drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |    4 +--
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    4 +--
>  drivers/staging/lustre/lustre/osc/osc_object.c     |    2 +
>  drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +
>  drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    6 ++--
>  16 files changed, 47 insertions(+), 61 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> index 0ebbde4ec8e8..172a8872e3f3 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> @@ -36,20 +36,6 @@
>  
>  #ifndef __LIBCFS_TIME_H__
>  #define __LIBCFS_TIME_H__
> -/*
> - * generic time manipulation functions.
> - */
> -
> -static inline int cfs_time_after(unsigned long t1, unsigned long t2)
> -{
> -	return time_before(t2, t1);
> -}
> -
> -static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
> -{
> -	return time_before_eq(t2, t1);
> -}
> -
>  /*
>   * return valid time-out based on user supplied one. Currently we only check
>   * that time-out is not shorted than allowed.
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index 276bf486f64b..d0ce37d72571 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -1522,7 +1522,7 @@ static int kiblnd_fmr_pool_is_idle(struct kib_fmr_pool *fpo, unsigned long now)
>  		return 0;
>  	if (fpo->fpo_failed)
>  		return 1;
> -	return cfs_time_aftereq(now, fpo->fpo_deadline);
> +	return time_after_eq(now, fpo->fpo_deadline);
>  }
>  
>  static int
> @@ -1850,7 +1850,7 @@ static int kiblnd_pool_is_idle(struct kib_pool *pool, unsigned long now)
>  		return 0;
>  	if (pool->po_failed)
>  		return 1;
> -	return cfs_time_aftereq(now, pool->po_deadline);
> +	return time_after_eq(now, pool->po_deadline);
>  }
>  
>  void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node)
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> index b18911d09e9a..ca6e09de0872 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
> @@ -754,9 +754,9 @@ static inline int
>  kiblnd_send_keepalive(struct kib_conn *conn)
>  {
>  	return (*kiblnd_tunables.kib_keepalive > 0) &&
> -		cfs_time_after(jiffies, conn->ibc_last_send +
> -			       msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
> -						MSEC_PER_SEC));
> +		time_after(jiffies, conn->ibc_last_send +
> +			   msecs_to_jiffies(*kiblnd_tunables.kib_keepalive *
> +					    MSEC_PER_SEC));
>  }
>  
>  static inline int
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> index f9761d8f2e3e..563ff5c972bf 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> @@ -3141,7 +3141,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs)
>  			LASSERT(tx->tx_waiting || tx->tx_sending);
>  		}
>  
> -		if (cfs_time_aftereq(jiffies, tx->tx_deadline)) {
> +		if (time_after_eq(jiffies, tx->tx_deadline)) {
>  			CERROR("Timed out tx: %s, %lu seconds\n",
>  			       kiblnd_queue2str(conn, txs),
>  			       cfs_duration_sec(jiffies - tx->tx_deadline));
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index 1ace54c9b133..8ead1e02e854 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -481,7 +481,7 @@ ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>  		LASSERT(conn->ksnc_tx_scheduled);
>  		list_add_tail(&conn->ksnc_tx_list,
>  			      &ksocknal_data.ksnd_enomem_conns);
> -		if (!cfs_time_aftereq(jiffies + SOCKNAL_ENOMEM_RETRY,
> +		if (!time_after_eq(jiffies + SOCKNAL_ENOMEM_RETRY,
>  				   ksocknal_data.ksnd_reaper_waketime))
>  			wake_up(&ksocknal_data.ksnd_reaper_waitq);
>  
> @@ -590,7 +590,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
>  		case SOCKNAL_MATCH_YES: /* typed connection */
>  			if (!typed || tnob > nob ||
>  			    (tnob == nob && *ksocknal_tunables.ksnd_round_robin &&
> -			     cfs_time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
> +			     time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
>  				typed = c;
>  				tnob  = nob;
>  			}
> @@ -599,7 +599,7 @@ ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx,
>  		case SOCKNAL_MATCH_MAY: /* fallback connection */
>  			if (!fallback || fnob > nob ||
>  			    (fnob == nob && *ksocknal_tunables.ksnd_round_robin &&
> -			     cfs_time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
> +			     time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
>  				fallback = c;
>  				fnob = nob;
>  			}
> @@ -745,7 +745,7 @@ ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
>  			continue;
>  
>  		if (!(!route->ksnr_retry_interval || /* first attempt */
> -		      cfs_time_aftereq(now, route->ksnr_timeout))) {
> +		      time_after_eq(now, route->ksnr_timeout))) {
>  			CDEBUG(D_NET,
>  			       "Too soon to retry route %pI4h (cnted %d, interval %ld, %ld secs later)\n",
>  			       &route->ksnr_ipaddr,
> @@ -1823,7 +1823,7 @@ ksocknal_connect(struct ksock_route *route)
>  
>  		write_unlock_bh(&ksocknal_data.ksnd_global_lock);
>  
> -		if (cfs_time_aftereq(jiffies, deadline)) {
> +		if (time_after_eq(jiffies, deadline)) {
>  			rc = -ETIMEDOUT;
>  			lnet_connect_console_error(rc, peer->ksnp_id.nid,
>  						   route->ksnr_ipaddr,
> @@ -2052,7 +2052,7 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
>  	list_for_each_entry(route, &ksocknal_data.ksnd_connd_routes,
>  			    ksnr_connd_list) {
>  		if (!route->ksnr_retry_interval ||
> -		    cfs_time_aftereq(now, route->ksnr_timeout))
> +		    time_after_eq(now, route->ksnr_timeout))
>  			return route;
>  
>  		if (*timeout_p == MAX_SCHEDULE_TIMEOUT ||
> @@ -2224,8 +2224,8 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
>  		}
>  
>  		if (conn->ksnc_rx_started &&
> -		    cfs_time_aftereq(jiffies,
> -				     conn->ksnc_rx_deadline)) {
> +		    time_after_eq(jiffies,
> +				  conn->ksnc_rx_deadline)) {
>  			/* Timed out incomplete incoming message */
>  			ksocknal_conn_addref(conn);
>  			CNETERR("Timeout receiving from %s (%pI4h:%d), state %d wanted %zd left %d\n",
> @@ -2240,8 +2240,8 @@ ksocknal_find_timed_out_conn(struct ksock_peer *peer)
>  
>  		if ((!list_empty(&conn->ksnc_tx_queue) ||
>  		     conn->ksnc_sock->sk->sk_wmem_queued) &&
> -		    cfs_time_aftereq(jiffies,
> -				     conn->ksnc_tx_deadline)) {
> +		    time_after_eq(jiffies,
> +				  conn->ksnc_tx_deadline)) {
>  			/*
>  			 * Timed out messages queued for sending or
>  			 * buffered in the socket's send buffer
> @@ -2268,8 +2268,8 @@ ksocknal_flush_stale_txs(struct ksock_peer *peer)
>  	write_lock_bh(&ksocknal_data.ksnd_global_lock);
>  
>  	list_for_each_entry_safe(tx, tmp, &peer->ksnp_tx_queue, tx_list) {
> -		if (!cfs_time_aftereq(jiffies,
> -				      tx->tx_deadline))
> +		if (!time_after_eq(jiffies,
> +				   tx->tx_deadline))
>  			break;
>  
>  		list_del(&tx->tx_list);
> @@ -2395,8 +2395,8 @@ ksocknal_check_peer_timeouts(int idx)
>  			tx = list_entry(peer->ksnp_tx_queue.next,
>  					struct ksock_tx, tx_list);
>  
> -			if (cfs_time_aftereq(jiffies,
> -					     tx->tx_deadline)) {
> +			if (time_after_eq(jiffies,
> +					  tx->tx_deadline)) {
>  				ksocknal_peer_addref(peer);
>  				read_unlock(&ksocknal_data.ksnd_global_lock);
>  
> @@ -2413,8 +2413,8 @@ ksocknal_check_peer_timeouts(int idx)
>  		tx_stale = NULL;
>  		spin_lock(&peer->ksnp_lock);
>  		list_for_each_entry(tx, &peer->ksnp_zc_req_list, tx_zc_list) {
> -			if (!cfs_time_aftereq(jiffies,
> -					      tx->tx_deadline))
> +			if (!time_after_eq(jiffies,
> +					   tx->tx_deadline))
>  				break;
>  			/* ignore the TX if connection is being closed */
>  			if (tx->tx_conn->ksnc_closing)
> diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> index 2aeae0331ee0..129430e74d00 100644
> --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
> +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> @@ -431,7 +431,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  	if (cdls) {
>  		if (libcfs_console_ratelimit &&
>  		    cdls->cdls_next &&		/* not first time ever */
> -		    !cfs_time_after(jiffies, cdls->cdls_next)) {
> +		    !time_after(jiffies, cdls->cdls_next)) {
>  			/* skipping a console message */
>  			cdls->cdls_count++;
>  			if (tcd)
> @@ -439,9 +439,9 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  			return 1;
>  		}
>  
> -		if (cfs_time_after(jiffies,
> -				   cdls->cdls_next + libcfs_console_max_delay +
> -				   10 * HZ)) {
> +		if (time_after(jiffies,
> +			       cdls->cdls_next + libcfs_console_max_delay +
> +			       10 * HZ)) {
>  			/* last timeout was a long time ago */
>  			cdls->cdls_delay /= libcfs_console_backoff * 4;
>  		} else {
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
> index 5574d2148c9d..60464135161b 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-move.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
> @@ -520,11 +520,11 @@ lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now)
>  	 * ignore the initial assumed death (see lnet_peers_start_down()).
>  	 */
>  	if (!lp->lp_alive && lp->lp_alive_count > 0 &&
> -	    cfs_time_aftereq(lp->lp_timestamp, lp->lp_last_alive))
> +	    time_after_eq(lp->lp_timestamp, lp->lp_last_alive))
>  		return 0;
>  
>  	deadline = lp->lp_last_alive + lp->lp_ni->ni_peertimeout * HZ;
> -	alive = cfs_time_after(deadline, now);
> +	alive = time_after(deadline, now);
>  
>  	/* Update obsolete lp_alive except for routers assumed to be dead
>  	 * initially, because router checker would update aliveness in this
> diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
> index 05d7b754815a..0066394b0bb0 100644
> --- a/drivers/staging/lustre/lnet/lnet/net_fault.c
> +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
> @@ -309,9 +309,9 @@ drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
>  		unsigned long now = jiffies;
>  
>  		rule->dr_stat.fs_count++;
> -		drop = cfs_time_aftereq(now, rule->dr_drop_time);
> +		drop = time_after_eq(now, rule->dr_drop_time);
>  		if (drop) {
> -			if (cfs_time_after(now, rule->dr_time_base))
> +			if (time_after(now, rule->dr_time_base))
>  				rule->dr_time_base = now;
>  
>  			rule->dr_drop_time = rule->dr_time_base +
> @@ -475,9 +475,9 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
>  		unsigned long now = jiffies;
>  
>  		rule->dl_stat.fs_count++;
> -		delay = cfs_time_aftereq(now, rule->dl_delay_time);
> +		delay = time_after_eq(now, rule->dl_delay_time);
>  		if (delay) {
> -			if (cfs_time_after(now, rule->dl_time_base))
> +			if (time_after(now, rule->dl_time_base))
>  				rule->dl_time_base = now;
>  
>  			rule->dl_delay_time = rule->dl_time_base +
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index c72d4f4454ec..8baf35d56ca7 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -982,7 +982,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
>  	lnet_peer_addref_locked(rtr);
>  
>  	if (rtr->lp_ping_deadline && /* ping timed out? */
> -	    cfs_time_after(now, rtr->lp_ping_deadline))
> +	    time_after(now, rtr->lp_ping_deadline))
>  		lnet_notify_locked(rtr, 1, 0, now);
>  
>  	/* Run any outstanding notifications */
> @@ -1010,7 +1010,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
>  	       rtr->lp_alive, rtr->lp_alive_count, rtr->lp_ping_timestamp);
>  
>  	if (secs && !rtr->lp_ping_notsent &&
> -	    cfs_time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
> +	    time_after(now, rtr->lp_ping_timestamp + secs * HZ)) {
>  		int rc;
>  		struct lnet_process_id id;
>  		struct lnet_handle_md mdh;
> @@ -1748,7 +1748,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
>  	}
>  
>  	/* can't do predictions... */
> -	if (cfs_time_after(when, now)) {
> +	if (time_after(when, now)) {
>  		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
>  		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
>  		      libcfs_nid2str(nid), alive ? "up" : "down",
> diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
> index ea4944b9108b..8c237758c3eb 100644
> --- a/drivers/staging/lustre/lnet/selftest/conrpc.c
> +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
> @@ -315,7 +315,7 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
>  			continue;
>  
>  		nd = crpc->crp_node;
> -		if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
> +		if (time_after(nd->nd_stamp, crpc->crp_stamp))
>  			continue;
>  
>  		nd->nd_stamp = crpc->crp_stamp;
> @@ -404,7 +404,7 @@ lstcon_rpc_get_reply(struct lstcon_rpc *crpc, struct srpc_msg **msgpp)
>  		crpc->crp_unpacked = 1;
>  	}
>  
> -	if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
> +	if (time_after(nd->nd_stamp, crpc->crp_stamp))
>  		return 0;
>  
>  	nd->nd_stamp = crpc->crp_stamp;
> diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
> index 1f9d5487e2f5..582f252b3e12 100644
> --- a/drivers/staging/lustre/lnet/selftest/timer.c
> +++ b/drivers/staging/lustre/lnet/selftest/timer.c
> @@ -155,7 +155,7 @@ stt_check_timers(unsigned long *last)
>  
>  	spin_lock(&stt_data.stt_lock);
>  
> -	while (cfs_time_aftereq(this_slot, *last)) {
> +	while (time_after_eq(this_slot, *last)) {
>  		expired += stt_expire_list(STTIMER_SLOT(this_slot), now);
>  		this_slot = this_slot - STTIMER_SLOTTIME;
>  	}
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> index 150e78c9eb68..942d34f7a44c 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
> @@ -325,8 +325,8 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
>  	lock_res_and_lock(lock);
>  	if (lock->l_granted_mode == LCK_PW &&
>  	    !lock->l_readers && !lock->l_writers &&
> -	    cfs_time_after(jiffies,
> -			   lock->l_last_used + 10 * HZ)) {
> +	    time_after(jiffies,
> +		       lock->l_last_used + 10 * HZ)) {
>  		unlock_res_and_lock(lock);
>  		if (ldlm_bl_to_thread_lock(ns, NULL, lock))
>  			ldlm_handle_bl_callback(ns, NULL, lock);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index 647e85b16c02..187095022fb1 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -116,7 +116,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
>  			   (s64)lock->l_last_activity,
>  			   (s64)(ktime_get_real_seconds() -
>  				 lock->l_last_activity));
> -		if (cfs_time_after(jiffies, next_dump)) {
> +		if (time_after(jiffies, next_dump)) {
>  			last_dump = next_dump;
>  			next_dump = jiffies + 300 * HZ;
>  			ldlm_namespace_dump(D_DLMTRACE,
> @@ -1176,7 +1176,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
>  	 * Despite of the LV, It doesn't make sense to keep the lock which
>  	 * is unused for ns_max_age time.
>  	 */
> -	if (cfs_time_after(jiffies, lock->l_last_used + ns->ns_max_age))
> +	if (time_after(jiffies, lock->l_last_used + ns->ns_max_age))
>  		return LDLM_POLICY_CANCEL_LOCK;
>  
>  	slv = ldlm_pool_get_slv(pl);
> diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c
> index 154d1721636e..84240181c7ea 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_object.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_object.c
> @@ -328,7 +328,7 @@ int osc_object_is_contended(struct osc_object *obj)
>  	 * ll_file_is_contended.
>  	 */
>  	retry_time = obj->oo_contention_time + osc_contention_time * HZ;
> -	if (cfs_time_after(cur_time, retry_time)) {
> +	if (time_after(cur_time, retry_time)) {
>  		osc_object_clear_contended(obj);
>  		return 0;
>  	}
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 04d801f11ace..0038e555e905 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -748,7 +748,7 @@ static int osc_should_shrink_grant(struct client_obd *client)
>  	     OBD_CONNECT_GRANT_SHRINK) == 0)
>  		return 0;
>  
> -	if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) {
> +	if (time_after_eq(time, next_shrink - 5 * CFS_TICK)) {
>  		/* Get the current RPC size directly, instead of going via:
>  		 * cli_brw_size(obd->u.cli.cl_import->imp_obd->obd_self_export)
>  		 * Keep comment here so that it can be found by searching.
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> index 7057b4447035..3f17c673d1b8 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> @@ -180,7 +180,7 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp,
>  
>  	imp->imp_force_verify = 0;
>  
> -	if (cfs_time_aftereq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
> +	if (time_after_eq(imp->imp_next_ping - 5 * CFS_TICK, this_ping) &&
>  	    !force) {
>  		spin_unlock(&imp->imp_lock);
>  		return;
> @@ -236,8 +236,8 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
>  			ptlrpc_pinger_process_import(imp, this_ping);
>  			/* obd_timeout might have changed */
>  			if (imp->imp_pingable && imp->imp_next_ping &&
> -			    cfs_time_after(imp->imp_next_ping,
> -					   this_ping + PING_INTERVAL * HZ))
> +			    time_after(imp->imp_next_ping,
> +				       this_ping + PING_INTERVAL * HZ))
>  				ptlrpc_update_next_ping(imp, 0);
>  		}
>  		mutex_unlock(&pinger_mutex);
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 19:02     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:02 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> This function simply multiplies by HZ and adds jiffies.
> This is simple enough to be opencoded, and doing so
> makes the code easier to read.
> 
> Same for cfs_time_shift_64()

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/libcfs_time.h      |    5 ----
>  .../lustre/include/linux/libcfs/linux/linux-time.h |    5 ----
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   12 +++++----
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    4 ++-
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 ++-
>  .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   12 +++++----
>  drivers/staging/lustre/lnet/lnet/net_fault.c       |   26 ++++++++++----------
>  drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    2 +-
>  drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 +-
>  drivers/staging/lustre/lustre/llite/llite_lib.c    |    4 ++-
>  drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +++++----
>  drivers/staging/lustre/lustre/llite/statahead.c    |    2 +-
>  drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    2 +-
>  drivers/staging/lustre/lustre/lov/lov_obd.c        |    2 +-
>  drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 +-
>  .../lustre/lustre/obdclass/lprocfs_status.c        |   12 +++++----
>  .../staging/lustre/lustre/obdclass/obd_config.c    |    2 +-
>  drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +-
>  drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    6 ++---
>  drivers/staging/lustre/lustre/ptlrpc/service.c     |    2 +-
>  21 files changed, 56 insertions(+), 66 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> index 7b41a129f041..0ebbde4ec8e8 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> @@ -50,11 +50,6 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
>  	return time_before_eq(t2, t1);
>  }
>  
> -static inline unsigned long cfs_time_shift(int seconds)
> -{
> -	return jiffies + seconds * HZ;
> -}
> -
>  /*
>   * return valid time-out based on user supplied one. Currently we only check
>   * that time-out is not shorted than allowed.
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index b3a80531bd71..ff3aae2f1231 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -65,11 +65,6 @@ static inline long cfs_duration_sec(long d)
>  	return d / msecs_to_jiffies(MSEC_PER_SEC);
>  }
>  
> -static inline u64 cfs_time_shift_64(int seconds)
> -{
> -	return get_jiffies_64() + (u64)seconds * HZ;
> -}
> -
>  static inline int cfs_time_before_64(u64 t1, u64 t2)
>  {
>  	return (__s64)t2 - (__s64)t1 > 0;
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index 7df07f39b849..276bf486f64b 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -1446,7 +1446,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps,
>  	if (rc)
>  		goto out_fpo;
>  
> -	fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
> +	fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>  	fpo->fpo_owner = fps;
>  	*pp_fpo = fpo;
>  
> @@ -1619,7 +1619,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
>  	spin_lock(&fps->fps_lock);
>  	version = fps->fps_version;
>  	list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
> -		fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
> +		fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>  		fpo->fpo_map_count++;
>  
>  		if (fpo->fpo_is_fmr) {
> @@ -1743,7 +1743,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
>  		fps->fps_version++;
>  		list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
>  	} else {
> -		fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
> +		fps->fps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
>  	}
>  	spin_unlock(&fps->fps_lock);
>  
> @@ -1764,7 +1764,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, struct kib_pool *pool, int
>  
>  	memset(pool, 0, sizeof(*pool));
>  	INIT_LIST_HEAD(&pool->po_free_list);
> -	pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
> +	pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>  	pool->po_owner    = ps;
>  	pool->po_size     = size;
>  }
> @@ -1899,7 +1899,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>  			continue;
>  
>  		pool->po_allocated++;
> -		pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
> +		pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>  		node = pool->po_free_list.next;
>  		list_del(node);
>  
> @@ -1947,7 +1947,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>  	if (!rc) {
>  		list_add_tail(&pool->po_list, &ps->ps_pool_list);
>  	} else {
> -		ps->ps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
> +		ps->ps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
>  		CERROR("Can't allocate new %s pool because out of memory\n",
>  		       ps->ps_name);
>  	}
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> index c1c3277f4c1f..f9761d8f2e3e 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> @@ -3700,13 +3700,13 @@ kiblnd_failover_thread(void *arg)
>  			LASSERT(dev->ibd_failover);
>  			dev->ibd_failover = 0;
>  			if (rc >= 0) { /* Device is OK or failover succeed */
> -				dev->ibd_next_failover = cfs_time_shift(3);
> +				dev->ibd_next_failover = jiffies + 3 * HZ;
>  				continue;
>  			}
>  
>  			/* failed to failover, retry later */
>  			dev->ibd_next_failover =
> -				cfs_time_shift(min(dev->ibd_failed_failover, 10));
> +				jiffies + min(dev->ibd_failed_failover, 10) * HZ;
>  			if (kiblnd_dev_can_failover(dev)) {
>  				list_add_tail(&dev->ibd_fail_list,
>  					      &kiblnd_data.kib_failed_devs);
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 4546618c1c12..16c1ab0b0bd9 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -1287,7 +1287,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
>  	conn->ksnc_tx_last_post = jiffies;
>  	/* Set the deadline for the outgoing HELLO to drain */
>  	conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
> -	conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +	conn->ksnc_tx_deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  	mb();   /* order with adding to peer's conn list */
>  
>  	list_add(&conn->ksnc_list, &peer->ksnp_conns);
> @@ -1852,7 +1852,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
>  			if (bufnob < conn->ksnc_tx_bufnob) {
>  				/* something got ACKed */
>  				conn->ksnc_tx_deadline =
> -					cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +					jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  				peer->ksnp_last_alive = now;
>  				conn->ksnc_tx_bufnob = bufnob;
>  			}
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index 5b34c7c030ad..1ace54c9b133 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -221,7 +221,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>  			 * something got ACKed
>  			 */
>  			conn->ksnc_tx_deadline =
> -				cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +				jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  			conn->ksnc_peer->ksnp_last_alive = jiffies;
>  			conn->ksnc_tx_bufnob = bufnob;
>  			mb();
> @@ -269,7 +269,7 @@ ksocknal_recv_iter(struct ksock_conn *conn)
>  
>  	conn->ksnc_peer->ksnp_last_alive = jiffies;
>  	conn->ksnc_rx_deadline =
> -		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  	mb();		       /* order with setting rx_started */
>  	conn->ksnc_rx_started = 1;
>  
> @@ -405,7 +405,7 @@ ksocknal_check_zc_req(struct ksock_tx *tx)
>  
>  	/* ZC_REQ is going to be pinned to the peer */
>  	tx->tx_deadline =
> -		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  
>  	LASSERT(!tx->tx_msg.ksm_zc_cookies[0]);
>  
> @@ -677,7 +677,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
>  	if (list_empty(&conn->ksnc_tx_queue) && !bufnob) {
>  		/* First packet starts the timeout */
>  		conn->ksnc_tx_deadline =
> -			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  		if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
>  			conn->ksnc_peer->ksnp_last_alive = jiffies;
>  		conn->ksnc_tx_bufnob = 0;
> @@ -858,7 +858,7 @@ ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
>  	    ksocknal_find_connecting_route_locked(peer)) {
>  		/* the message is going to be pinned to the peer */
>  		tx->tx_deadline =
> -			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  
>  		/* Queue the message until a connection is established */
>  		list_add_tail(&tx->tx_list, &peer->ksnp_tx_queue);
> @@ -2308,7 +2308,7 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
>  	 * retry 10 secs later, so we wouldn't put pressure
>  	 * on this peer if we failed to send keepalive this time
>  	 */
> -	peer->ksnp_send_keepalive = cfs_time_shift(10);
> +	peer->ksnp_send_keepalive = jiffies + 10 * HZ;
>  
>  	conn = ksocknal_find_conn_locked(peer, NULL, 1);
>  	if (conn) {
> diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
> index 3928e9a74d6f..05d7b754815a 100644
> --- a/drivers/staging/lustre/lnet/lnet/net_fault.c
> +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
> @@ -169,9 +169,9 @@ lnet_drop_rule_add(struct lnet_fault_attr *attr)
>  
>  	rule->dr_attr = *attr;
>  	if (attr->u.drop.da_interval) {
> -		rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
> -		rule->dr_drop_time = cfs_time_shift(
> -			prandom_u32_max(attr->u.drop.da_interval));
> +		rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
> +		rule->dr_drop_time = jiffies +
> +			prandom_u32_max(attr->u.drop.da_interval) * HZ;
>  	} else {
>  		rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
>  	}
> @@ -279,9 +279,9 @@ lnet_drop_rule_reset(void)
>  		if (attr->u.drop.da_rate) {
>  			rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
>  		} else {
> -			rule->dr_drop_time = cfs_time_shift(
> -				prandom_u32_max(attr->u.drop.da_interval));
> -			rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
> +			rule->dr_drop_time = jiffies +
> +				prandom_u32_max(attr->u.drop.da_interval) * HZ;
> +			rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
>  		}
>  		spin_unlock(&rule->dr_lock);
>  	}
> @@ -513,7 +513,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
>  
>  	list_add_tail(&msg->msg_list, &rule->dl_msg_list);
>  	msg->msg_delay_send = round_timeout(
> -			cfs_time_shift(attr->u.delay.la_latency));
> +			jiffies + attr->u.delay.la_latency * HZ);
>  	if (rule->dl_msg_send == -1) {
>  		rule->dl_msg_send = msg->msg_delay_send;
>  		mod_timer(&rule->dl_timer, rule->dl_msg_send);
> @@ -767,9 +767,9 @@ lnet_delay_rule_add(struct lnet_fault_attr *attr)
>  
>  	rule->dl_attr = *attr;
>  	if (attr->u.delay.la_interval) {
> -		rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
> -		rule->dl_delay_time = cfs_time_shift(
> -			prandom_u32_max(attr->u.delay.la_interval));
> +		rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
> +		rule->dl_delay_time = jiffies + 
> +			prandom_u32_max(attr->u.delay.la_interval) * HZ;
>  	} else {
>  		rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
>  	}
> @@ -920,9 +920,9 @@ lnet_delay_rule_reset(void)
>  			rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
>  		} else {
>  			rule->dl_delay_time =
> -				cfs_time_shift(prandom_u32_max(
> -						       attr->u.delay.la_interval));
> -			rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
> +				jiffies + prandom_u32_max(
> +					attr->u.delay.la_interval) * HZ;
> +			rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
>  		}
>  		spin_unlock(&rule->dl_lock);
>  	}
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index 4595a7ad4336..c72d4f4454ec 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -1026,7 +1026,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
>  
>  		if (!rtr->lp_ping_deadline) {
>  			rtr->lp_ping_deadline =
> -				cfs_time_shift(router_ping_timeout);
> +				jiffies + router_ping_timeout * HZ;
>  		}
>  
>  		lnet_net_unlock(rtr->lp_cpt);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index 6eb42f16040d..647e85b16c02 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -118,7 +118,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
>  				 lock->l_last_activity));
>  		if (cfs_time_after(jiffies, next_dump)) {
>  			last_dump = next_dump;
> -			next_dump = cfs_time_shift(300);
> +			next_dump = jiffies + 300 * HZ;
>  			ldlm_namespace_dump(D_DLMTRACE,
>  					    ldlm_lock_to_ns(lock));
>  			if (last_dump == 0)
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> index ccd0c082e39b..6c615b6e9bdc 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> @@ -1323,7 +1323,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
>  				 ldlm_res_hash_dump,
>  				 (void *)(unsigned long)level, 0);
>  	spin_lock(&ns->ns_lock);
> -	ns->ns_next_dump = cfs_time_shift(10);
> +	ns->ns_next_dump = jiffies + 10 * HZ;
>  	spin_unlock(&ns->ns_lock);
>  }
>  
> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
> index e7500c53fafc..60dbe888e336 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
> @@ -257,7 +257,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
>  	 * available
>  	 */
>  	err = obd_statfs(NULL, sbi->ll_md_exp, osfs,
> -			 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			 get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			 OBD_STATFS_FOR_MDT0);
>  	if (err)
>  		goto out_md_fid;
> @@ -1675,7 +1675,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
>  
>  	/* Some amount of caching on the client is allowed */
>  	rc = ll_statfs_internal(sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				0);
>  	if (rc)
>  		return rc;
> diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
> index 644bea2f9d37..164fe4d6b6b8 100644
> --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
> +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
> @@ -53,7 +53,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%u\n", osfs.os_bsize);
> @@ -71,7 +71,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -96,7 +96,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -121,7 +121,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -146,7 +146,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%llu\n", osfs.os_files);
> @@ -164,7 +164,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%llu\n", osfs.os_ffree);
> diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
> index 6f996acf6aa8..b4a6ee6c83f3 100644
> --- a/drivers/staging/lustre/lustre/llite/statahead.c
> +++ b/drivers/staging/lustre/lustre/llite/statahead.c
> @@ -523,7 +523,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
>  	 *    affect the performance.
>  	 */
>  	if (lli->lli_glimpse_time != 0 &&
> -	    time_before(cfs_time_shift(-1), lli->lli_glimpse_time)) {
> +	    time_before(jiffies - 1 * HZ, lli->lli_glimpse_time)) {
>  		up_write(&lli->lli_glimpse_sem);
>  		lli->lli_agl_index = 0;
>  		iput(inode);
> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> index e8a9b9902c37..7be931039e3c 100644
> --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> @@ -876,7 +876,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
>  			return -EFAULT;
>  
>  		rc = obd_statfs(NULL, tgt->ltd_exp, &stat_buf,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				0);
>  		if (rc)
>  			return rc;
> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
> index ec70c12e5b40..355e87ecc62d 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
> @@ -1063,7 +1063,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
>  
>  		/* got statfs data */
>  		rc = obd_statfs(NULL, lov->lov_tgts[index]->ltd_exp, &stat_buf,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				flags);
>  		if (rc)
>  			return rc;
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> index 3b1c8e5a3053..266fa90cb03d 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> @@ -2104,7 +2104,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
>  		}
>  
>  		rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				0);
>  		if (rc != 0)
>  			goto out;
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index 2ed350527398..eb6396add78d 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -407,7 +407,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%u\n", osfs.os_bsize);
> @@ -423,7 +423,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -446,7 +446,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -469,7 +469,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -492,7 +492,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%llu\n", osfs.os_files);
> @@ -508,7 +508,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%llu\n", osfs.os_ffree);
> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
> index 277576b586db..eab03766236f 100644
> --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
> +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
> @@ -269,7 +269,7 @@ static int class_attach(struct lustre_cfg *lcfg)
>  	/* obd->obd_osfs_age must be set to a value in the distant
>  	 * past to guarantee a fresh statfs is fetched on mount.
>  	 */
> -	obd->obd_osfs_age = cfs_time_shift_64(-1000);
> +	obd->obd_osfs_age = get_jiffies_64() - 1000 * HZ;
>  
>  	/* XXX belongs in setup not attach  */
>  	init_rwsem(&obd->obd_observer_link_sem);
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 9966fc7af789..04d801f11ace 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -617,7 +617,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
>  void osc_update_next_shrink(struct client_obd *cli)
>  {
>  	cli->cl_next_shrink_grant =
> -		cfs_time_shift(cli->cl_grant_shrink_interval);
> +		jiffies + cli->cl_grant_shrink_interval * HZ;
>  	CDEBUG(D_CACHE, "next time %ld to shrink grant\n",
>  	       cli->cl_next_shrink_grant);
>  }
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> index e836591c5936..7057b4447035 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> @@ -108,7 +108,7 @@ static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
>  				  at_get(&imp->imp_at.iat_net_latency));
>  		time = min(time, dtime);
>  	}
> -	imp->imp_next_ping = cfs_time_shift(time);
> +	imp->imp_next_ping = jiffies + time * HZ;
>  }
>  
>  static inline int imp_is_deactive(struct obd_import *imp)
> @@ -120,9 +120,9 @@ static inline int imp_is_deactive(struct obd_import *imp)
>  static inline int ptlrpc_next_reconnect(struct obd_import *imp)
>  {
>  	if (imp->imp_server_timeout)
> -		return cfs_time_shift(obd_timeout / 2);
> +		return jiffies + obd_timeout / 2 * HZ;
>  	else
> -		return cfs_time_shift(obd_timeout);
> +		return jiffies + obd_timeout * HZ;
>  }
>  
>  static long pinger_check_timeout(unsigned long time)
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
> index e71046db28e5..4265e8d00ca5 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
> @@ -922,7 +922,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
>  	if (next <= 0) {
>  		ptlrpc_at_timer(&svcpt->scp_at_timer);
>  	} else {
> -		mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
> +		mod_timer(&svcpt->scp_at_timer, jiffies + next * HZ);
>  		CDEBUG(D_INFO, "armed %s at %+ds\n",
>  		       svcpt->scp_service->srv_name, next);
>  	}
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
@ 2018-03-30 19:02     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:02 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> This function simply multiplies by HZ and adds jiffies.
> This is simple enough to be opencoded, and doing so
> makes the code easier to read.
> 
> Same for cfs_time_shift_64()

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/libcfs_time.h      |    5 ----
>  .../lustre/include/linux/libcfs/linux/linux-time.h |    5 ----
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   12 +++++----
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    4 ++-
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 ++-
>  .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   12 +++++----
>  drivers/staging/lustre/lnet/lnet/net_fault.c       |   26 ++++++++++----------
>  drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    2 +-
>  drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 +-
>  drivers/staging/lustre/lustre/llite/llite_lib.c    |    4 ++-
>  drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +++++----
>  drivers/staging/lustre/lustre/llite/statahead.c    |    2 +-
>  drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    2 +-
>  drivers/staging/lustre/lustre/lov/lov_obd.c        |    2 +-
>  drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 +-
>  .../lustre/lustre/obdclass/lprocfs_status.c        |   12 +++++----
>  .../staging/lustre/lustre/obdclass/obd_config.c    |    2 +-
>  drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +-
>  drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    6 ++---
>  drivers/staging/lustre/lustre/ptlrpc/service.c     |    2 +-
>  21 files changed, 56 insertions(+), 66 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> index 7b41a129f041..0ebbde4ec8e8 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> @@ -50,11 +50,6 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
>  	return time_before_eq(t2, t1);
>  }
>  
> -static inline unsigned long cfs_time_shift(int seconds)
> -{
> -	return jiffies + seconds * HZ;
> -}
> -
>  /*
>   * return valid time-out based on user supplied one. Currently we only check
>   * that time-out is not shorted than allowed.
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index b3a80531bd71..ff3aae2f1231 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -65,11 +65,6 @@ static inline long cfs_duration_sec(long d)
>  	return d / msecs_to_jiffies(MSEC_PER_SEC);
>  }
>  
> -static inline u64 cfs_time_shift_64(int seconds)
> -{
> -	return get_jiffies_64() + (u64)seconds * HZ;
> -}
> -
>  static inline int cfs_time_before_64(u64 t1, u64 t2)
>  {
>  	return (__s64)t2 - (__s64)t1 > 0;
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index 7df07f39b849..276bf486f64b 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -1446,7 +1446,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps,
>  	if (rc)
>  		goto out_fpo;
>  
> -	fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
> +	fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>  	fpo->fpo_owner = fps;
>  	*pp_fpo = fpo;
>  
> @@ -1619,7 +1619,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
>  	spin_lock(&fps->fps_lock);
>  	version = fps->fps_version;
>  	list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
> -		fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
> +		fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>  		fpo->fpo_map_count++;
>  
>  		if (fpo->fpo_is_fmr) {
> @@ -1743,7 +1743,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
>  		fps->fps_version++;
>  		list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
>  	} else {
> -		fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
> +		fps->fps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
>  	}
>  	spin_unlock(&fps->fps_lock);
>  
> @@ -1764,7 +1764,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, struct kib_pool *pool, int
>  
>  	memset(pool, 0, sizeof(*pool));
>  	INIT_LIST_HEAD(&pool->po_free_list);
> -	pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
> +	pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>  	pool->po_owner    = ps;
>  	pool->po_size     = size;
>  }
> @@ -1899,7 +1899,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>  			continue;
>  
>  		pool->po_allocated++;
> -		pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
> +		pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>  		node = pool->po_free_list.next;
>  		list_del(node);
>  
> @@ -1947,7 +1947,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>  	if (!rc) {
>  		list_add_tail(&pool->po_list, &ps->ps_pool_list);
>  	} else {
> -		ps->ps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
> +		ps->ps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
>  		CERROR("Can't allocate new %s pool because out of memory\n",
>  		       ps->ps_name);
>  	}
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> index c1c3277f4c1f..f9761d8f2e3e 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> @@ -3700,13 +3700,13 @@ kiblnd_failover_thread(void *arg)
>  			LASSERT(dev->ibd_failover);
>  			dev->ibd_failover = 0;
>  			if (rc >= 0) { /* Device is OK or failover succeed */
> -				dev->ibd_next_failover = cfs_time_shift(3);
> +				dev->ibd_next_failover = jiffies + 3 * HZ;
>  				continue;
>  			}
>  
>  			/* failed to failover, retry later */
>  			dev->ibd_next_failover =
> -				cfs_time_shift(min(dev->ibd_failed_failover, 10));
> +				jiffies + min(dev->ibd_failed_failover, 10) * HZ;
>  			if (kiblnd_dev_can_failover(dev)) {
>  				list_add_tail(&dev->ibd_fail_list,
>  					      &kiblnd_data.kib_failed_devs);
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 4546618c1c12..16c1ab0b0bd9 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -1287,7 +1287,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
>  	conn->ksnc_tx_last_post = jiffies;
>  	/* Set the deadline for the outgoing HELLO to drain */
>  	conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
> -	conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +	conn->ksnc_tx_deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  	mb();   /* order with adding to peer's conn list */
>  
>  	list_add(&conn->ksnc_list, &peer->ksnp_conns);
> @@ -1852,7 +1852,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
>  			if (bufnob < conn->ksnc_tx_bufnob) {
>  				/* something got ACKed */
>  				conn->ksnc_tx_deadline =
> -					cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +					jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  				peer->ksnp_last_alive = now;
>  				conn->ksnc_tx_bufnob = bufnob;
>  			}
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index 5b34c7c030ad..1ace54c9b133 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -221,7 +221,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>  			 * something got ACKed
>  			 */
>  			conn->ksnc_tx_deadline =
> -				cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +				jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  			conn->ksnc_peer->ksnp_last_alive = jiffies;
>  			conn->ksnc_tx_bufnob = bufnob;
>  			mb();
> @@ -269,7 +269,7 @@ ksocknal_recv_iter(struct ksock_conn *conn)
>  
>  	conn->ksnc_peer->ksnp_last_alive = jiffies;
>  	conn->ksnc_rx_deadline =
> -		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  	mb();		       /* order with setting rx_started */
>  	conn->ksnc_rx_started = 1;
>  
> @@ -405,7 +405,7 @@ ksocknal_check_zc_req(struct ksock_tx *tx)
>  
>  	/* ZC_REQ is going to be pinned to the peer */
>  	tx->tx_deadline =
> -		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  
>  	LASSERT(!tx->tx_msg.ksm_zc_cookies[0]);
>  
> @@ -677,7 +677,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
>  	if (list_empty(&conn->ksnc_tx_queue) && !bufnob) {
>  		/* First packet starts the timeout */
>  		conn->ksnc_tx_deadline =
> -			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  		if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
>  			conn->ksnc_peer->ksnp_last_alive = jiffies;
>  		conn->ksnc_tx_bufnob = 0;
> @@ -858,7 +858,7 @@ ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
>  	    ksocknal_find_connecting_route_locked(peer)) {
>  		/* the message is going to be pinned to the peer */
>  		tx->tx_deadline =
> -			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
> +			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>  
>  		/* Queue the message until a connection is established */
>  		list_add_tail(&tx->tx_list, &peer->ksnp_tx_queue);
> @@ -2308,7 +2308,7 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
>  	 * retry 10 secs later, so we wouldn't put pressure
>  	 * on this peer if we failed to send keepalive this time
>  	 */
> -	peer->ksnp_send_keepalive = cfs_time_shift(10);
> +	peer->ksnp_send_keepalive = jiffies + 10 * HZ;
>  
>  	conn = ksocknal_find_conn_locked(peer, NULL, 1);
>  	if (conn) {
> diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
> index 3928e9a74d6f..05d7b754815a 100644
> --- a/drivers/staging/lustre/lnet/lnet/net_fault.c
> +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
> @@ -169,9 +169,9 @@ lnet_drop_rule_add(struct lnet_fault_attr *attr)
>  
>  	rule->dr_attr = *attr;
>  	if (attr->u.drop.da_interval) {
> -		rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
> -		rule->dr_drop_time = cfs_time_shift(
> -			prandom_u32_max(attr->u.drop.da_interval));
> +		rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
> +		rule->dr_drop_time = jiffies +
> +			prandom_u32_max(attr->u.drop.da_interval) * HZ;
>  	} else {
>  		rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
>  	}
> @@ -279,9 +279,9 @@ lnet_drop_rule_reset(void)
>  		if (attr->u.drop.da_rate) {
>  			rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
>  		} else {
> -			rule->dr_drop_time = cfs_time_shift(
> -				prandom_u32_max(attr->u.drop.da_interval));
> -			rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
> +			rule->dr_drop_time = jiffies +
> +				prandom_u32_max(attr->u.drop.da_interval) * HZ;
> +			rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
>  		}
>  		spin_unlock(&rule->dr_lock);
>  	}
> @@ -513,7 +513,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
>  
>  	list_add_tail(&msg->msg_list, &rule->dl_msg_list);
>  	msg->msg_delay_send = round_timeout(
> -			cfs_time_shift(attr->u.delay.la_latency));
> +			jiffies + attr->u.delay.la_latency * HZ);
>  	if (rule->dl_msg_send == -1) {
>  		rule->dl_msg_send = msg->msg_delay_send;
>  		mod_timer(&rule->dl_timer, rule->dl_msg_send);
> @@ -767,9 +767,9 @@ lnet_delay_rule_add(struct lnet_fault_attr *attr)
>  
>  	rule->dl_attr = *attr;
>  	if (attr->u.delay.la_interval) {
> -		rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
> -		rule->dl_delay_time = cfs_time_shift(
> -			prandom_u32_max(attr->u.delay.la_interval));
> +		rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
> +		rule->dl_delay_time = jiffies + 
> +			prandom_u32_max(attr->u.delay.la_interval) * HZ;
>  	} else {
>  		rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
>  	}
> @@ -920,9 +920,9 @@ lnet_delay_rule_reset(void)
>  			rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
>  		} else {
>  			rule->dl_delay_time =
> -				cfs_time_shift(prandom_u32_max(
> -						       attr->u.delay.la_interval));
> -			rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
> +				jiffies + prandom_u32_max(
> +					attr->u.delay.la_interval) * HZ;
> +			rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
>  		}
>  		spin_unlock(&rule->dl_lock);
>  	}
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index 4595a7ad4336..c72d4f4454ec 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -1026,7 +1026,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
>  
>  		if (!rtr->lp_ping_deadline) {
>  			rtr->lp_ping_deadline =
> -				cfs_time_shift(router_ping_timeout);
> +				jiffies + router_ping_timeout * HZ;
>  		}
>  
>  		lnet_net_unlock(rtr->lp_cpt);
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index 6eb42f16040d..647e85b16c02 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -118,7 +118,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
>  				 lock->l_last_activity));
>  		if (cfs_time_after(jiffies, next_dump)) {
>  			last_dump = next_dump;
> -			next_dump = cfs_time_shift(300);
> +			next_dump = jiffies + 300 * HZ;
>  			ldlm_namespace_dump(D_DLMTRACE,
>  					    ldlm_lock_to_ns(lock));
>  			if (last_dump == 0)
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> index ccd0c082e39b..6c615b6e9bdc 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> @@ -1323,7 +1323,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
>  				 ldlm_res_hash_dump,
>  				 (void *)(unsigned long)level, 0);
>  	spin_lock(&ns->ns_lock);
> -	ns->ns_next_dump = cfs_time_shift(10);
> +	ns->ns_next_dump = jiffies + 10 * HZ;
>  	spin_unlock(&ns->ns_lock);
>  }
>  
> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
> index e7500c53fafc..60dbe888e336 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
> @@ -257,7 +257,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
>  	 * available
>  	 */
>  	err = obd_statfs(NULL, sbi->ll_md_exp, osfs,
> -			 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			 get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			 OBD_STATFS_FOR_MDT0);
>  	if (err)
>  		goto out_md_fid;
> @@ -1675,7 +1675,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
>  
>  	/* Some amount of caching on the client is allowed */
>  	rc = ll_statfs_internal(sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				0);
>  	if (rc)
>  		return rc;
> diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
> index 644bea2f9d37..164fe4d6b6b8 100644
> --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
> +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
> @@ -53,7 +53,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%u\n", osfs.os_bsize);
> @@ -71,7 +71,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -96,7 +96,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -121,7 +121,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -146,7 +146,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%llu\n", osfs.os_files);
> @@ -164,7 +164,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
>  	int rc;
>  
>  	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%llu\n", osfs.os_ffree);
> diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
> index 6f996acf6aa8..b4a6ee6c83f3 100644
> --- a/drivers/staging/lustre/lustre/llite/statahead.c
> +++ b/drivers/staging/lustre/lustre/llite/statahead.c
> @@ -523,7 +523,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
>  	 *    affect the performance.
>  	 */
>  	if (lli->lli_glimpse_time != 0 &&
> -	    time_before(cfs_time_shift(-1), lli->lli_glimpse_time)) {
> +	    time_before(jiffies - 1 * HZ, lli->lli_glimpse_time)) {
>  		up_write(&lli->lli_glimpse_sem);
>  		lli->lli_agl_index = 0;
>  		iput(inode);
> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> index e8a9b9902c37..7be931039e3c 100644
> --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
> @@ -876,7 +876,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
>  			return -EFAULT;
>  
>  		rc = obd_statfs(NULL, tgt->ltd_exp, &stat_buf,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				0);
>  		if (rc)
>  			return rc;
> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
> index ec70c12e5b40..355e87ecc62d 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
> @@ -1063,7 +1063,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
>  
>  		/* got statfs data */
>  		rc = obd_statfs(NULL, lov->lov_tgts[index]->ltd_exp, &stat_buf,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				flags);
>  		if (rc)
>  			return rc;
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> index 3b1c8e5a3053..266fa90cb03d 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> @@ -2104,7 +2104,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
>  		}
>  
>  		rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf,
> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  				0);
>  		if (rc != 0)
>  			goto out;
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index 2ed350527398..eb6396add78d 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -407,7 +407,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%u\n", osfs.os_bsize);
> @@ -423,7 +423,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -446,7 +446,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -469,7 +469,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc) {
>  		__u32 blk_size = osfs.os_bsize >> 10;
> @@ -492,7 +492,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%llu\n", osfs.os_files);
> @@ -508,7 +508,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
>  					      obd_kobj);
>  	struct obd_statfs  osfs;
>  	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>  			    OBD_STATFS_NODELAY);
>  	if (!rc)
>  		return sprintf(buf, "%llu\n", osfs.os_ffree);
> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
> index 277576b586db..eab03766236f 100644
> --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
> +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
> @@ -269,7 +269,7 @@ static int class_attach(struct lustre_cfg *lcfg)
>  	/* obd->obd_osfs_age must be set to a value in the distant
>  	 * past to guarantee a fresh statfs is fetched on mount.
>  	 */
> -	obd->obd_osfs_age = cfs_time_shift_64(-1000);
> +	obd->obd_osfs_age = get_jiffies_64() - 1000 * HZ;
>  
>  	/* XXX belongs in setup not attach  */
>  	init_rwsem(&obd->obd_observer_link_sem);
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 9966fc7af789..04d801f11ace 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -617,7 +617,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
>  void osc_update_next_shrink(struct client_obd *cli)
>  {
>  	cli->cl_next_shrink_grant =
> -		cfs_time_shift(cli->cl_grant_shrink_interval);
> +		jiffies + cli->cl_grant_shrink_interval * HZ;
>  	CDEBUG(D_CACHE, "next time %ld to shrink grant\n",
>  	       cli->cl_next_shrink_grant);
>  }
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> index e836591c5936..7057b4447035 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> @@ -108,7 +108,7 @@ static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
>  				  at_get(&imp->imp_at.iat_net_latency));
>  		time = min(time, dtime);
>  	}
> -	imp->imp_next_ping = cfs_time_shift(time);
> +	imp->imp_next_ping = jiffies + time * HZ;
>  }
>  
>  static inline int imp_is_deactive(struct obd_import *imp)
> @@ -120,9 +120,9 @@ static inline int imp_is_deactive(struct obd_import *imp)
>  static inline int ptlrpc_next_reconnect(struct obd_import *imp)
>  {
>  	if (imp->imp_server_timeout)
> -		return cfs_time_shift(obd_timeout / 2);
> +		return jiffies + obd_timeout / 2 * HZ;
>  	else
> -		return cfs_time_shift(obd_timeout);
> +		return jiffies + obd_timeout * HZ;
>  }
>  
>  static long pinger_check_timeout(unsigned long time)
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
> index e71046db28e5..4265e8d00ca5 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
> @@ -922,7 +922,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
>  	if (next <= 0) {
>  		ptlrpc_at_timer(&svcpt->scp_at_timer);
>  	} else {
> -		mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
> +		mod_timer(&svcpt->scp_at_timer, jiffies + next * HZ);
>  		CDEBUG(D_INFO, "armed %s at %+ds\n",
>  		       svcpt->scp_service->srv_name, next);
>  	}
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 14/17] staging: lustre: discard cfs_duration_sec()
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 19:02     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:02 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> cfs_duration_sec() simply divides by HZ.
> It is mostly used to report durations in debug messages.
> Remove and just use X/HZ.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/linux/linux-time.h |    5 -----
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    2 +-
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    5 ++---
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 ++--
>  .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |    4 ++--
>  drivers/staging/lustre/lnet/libcfs/debug.c         |    2 +-
>  drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
>  drivers/staging/lustre/lnet/lnet/router_proc.c     |    6 +++---
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    2 +-
>  9 files changed, 13 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index ecb2126a9e6f..9a353c6cb85a 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -60,11 +60,6 @@
>   * Generic kernel stuff
>   */
>  
> -static inline long cfs_duration_sec(long d)
> -{
> -	return d / msecs_to_jiffies(MSEC_PER_SEC);
> -}
> -
>  static inline int cfs_time_before_64(u64 t1, u64 t2)
>  {
>  	return (__s64)t2 - (__s64)t1 > 0;
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index d0ce37d72571..959e119384df 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -1068,7 +1068,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,
>  
>  	CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
>  	       libcfs_nid2str(nid), peer,
> -	       last_alive ? cfs_duration_sec(now - last_alive) : -1);
> +	       last_alive ? (now - last_alive) / HZ : -1);
>  }
>  
>  static void kiblnd_free_pages(struct kib_pages *p)
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> index 563ff5c972bf..b4a182d87ae7 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> @@ -3144,7 +3144,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs)
>  		if (time_after_eq(jiffies, tx->tx_deadline)) {
>  			CERROR("Timed out tx: %s, %lu seconds\n",
>  			       kiblnd_queue2str(conn, txs),
> -			       cfs_duration_sec(jiffies - tx->tx_deadline));
> +			       (jiffies - tx->tx_deadline) / HZ);
>  			return 1;
>  		}
>  	}
> @@ -3206,8 +3206,7 @@ kiblnd_check_conns(int idx)
>  			if (timedout) {
>  				CERROR("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n",
>  				       libcfs_nid2str(peer->ibp_nid),
> -				       cfs_duration_sec(jiffies -
> -							peer->ibp_last_alive),
> +				       (jiffies - peer->ibp_last_alive) / HZ,
>  				       conn->ibc_credits,
>  				       conn->ibc_outstanding_credits,
>  				       conn->ibc_reserved_credits);
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 16c1ab0b0bd9..79b98cdd0f9d 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
>  		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
>  		       &conn->ksnc_ipaddr, conn->ksnc_port,
>  		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
> -		       cfs_duration_sec(jiffies - last_rcv));
> +		       (jiffies - last_rcv) / HZ);
>  		lnet_finalize(conn->ksnc_peer->ksnp_ni,
>  			      conn->ksnc_cookie, -EIO);
>  		break;
> @@ -1870,7 +1870,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
>  
>  	CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago, connect %d\n",
>  	       libcfs_nid2str(nid), peer,
> -	       last_alive ? cfs_duration_sec(now - last_alive) : -1,
> +	       last_alive ? (now - last_alive) / HZ : -1,
>  	       connect);
>  
>  	if (!connect)
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index 8ead1e02e854..14450fd5957a 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -751,7 +751,7 @@ ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
>  			       &route->ksnr_ipaddr,
>  			       route->ksnr_connected,
>  			       route->ksnr_retry_interval,
> -			       cfs_duration_sec(route->ksnr_timeout - now));
> +			       (route->ksnr_timeout - now) / HZ);
>  			continue;
>  		}
>  
> @@ -2439,7 +2439,7 @@ ksocknal_check_peer_timeouts(int idx)
>  
>  		CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n",
>  		       n, libcfs_nid2str(peer->ksnp_id.nid), tx_stale,
> -		       cfs_duration_sec(jiffies - deadline),
> +		       (jiffies - deadline) / HZ,
>  		       resid, conn->ksnc_sock->sk->sk_wmem_queued);
>  
>  		ksocknal_close_conn_and_siblings(conn, -ETIMEDOUT);
> diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c
> index 1371224a8cb9..5862f0730dd0 100644
> --- a/drivers/staging/lustre/lnet/libcfs/debug.c
> +++ b/drivers/staging/lustre/lnet/libcfs/debug.c
> @@ -126,7 +126,7 @@ static int param_get_delay(char *buffer, const struct kernel_param *kp)
>  {
>  	unsigned int d = *(unsigned int *)kp->arg;
>  
> -	return sprintf(buffer, "%u", (unsigned int)cfs_duration_sec(d * 100));
> +	return sprintf(buffer, "%u", (unsigned int)(d * 100) / HZ);
>  }
>  
>  unsigned int libcfs_console_max_delay;
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index 8baf35d56ca7..6267d5e4bbd6 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -1752,7 +1752,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
>  		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
>  		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
>  		      libcfs_nid2str(nid), alive ? "up" : "down",
> -		      cfs_duration_sec(when - now));
> +		      (when - now) / HZ);
>  		return -EINVAL;
>  	}
>  
> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
> index e4172311be68..015dccbc4a58 100644
> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c
> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
> @@ -331,7 +331,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
>  			int alive_cnt = peer->lp_alive_count;
>  			int alive = peer->lp_alive;
>  			int pingsent = !peer->lp_ping_notsent;
> -			int last_ping = cfs_duration_sec(now - peer->lp_ping_timestamp);
> +			int last_ping = (now - peer->lp_ping_timestamp) / HZ;
>  			int down_ni = 0;
>  			struct lnet_route *rtr;
>  
> @@ -363,7 +363,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
>  					      nrefs, nrtrrefs, alive_cnt,
>  					      alive ? "up" : "down", last_ping,
>  					      pingsent,
> -					      cfs_duration_sec(deadline - now),
> +					      (deadline - now) / HZ,
>  					      down_ni, libcfs_nid2str(nid));
>  			LASSERT(tmpstr + tmpsiz - s > 0);
>  		}
> @@ -512,7 +512,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
>  				long delta;
>  
>  				delta = now - peer->lp_last_alive;
> -				lastalive = cfs_duration_sec(delta);
> +				lastalive = (delta) / HZ;
>  
>  				/* No need to mess up peers contents with
>  				 * arbitrarily long integers - it suffices to
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index 187095022fb1..f573de9cf45d 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -1181,7 +1181,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
>  
>  	slv = ldlm_pool_get_slv(pl);
>  	lvf = ldlm_pool_get_lvf(pl);
> -	la = cfs_duration_sec(cur - lock->l_last_used);
> +	la = (cur - lock->l_last_used) / HZ;
>  	lv = lvf * la * unused;
>  
>  	/* Inform pool about current CLV to see it via debugfs. */
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 14/17] staging: lustre: discard cfs_duration_sec()
@ 2018-03-30 19:02     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:02 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> cfs_duration_sec() simply divides by HZ.
> It is mostly used to report durations in debug messages.
> Remove and just use X/HZ.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/linux/linux-time.h |    5 -----
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |    2 +-
>  .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    5 ++---
>  .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 ++--
>  .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |    4 ++--
>  drivers/staging/lustre/lnet/libcfs/debug.c         |    2 +-
>  drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
>  drivers/staging/lustre/lnet/lnet/router_proc.c     |    6 +++---
>  drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    2 +-
>  9 files changed, 13 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index ecb2126a9e6f..9a353c6cb85a 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -60,11 +60,6 @@
>   * Generic kernel stuff
>   */
>  
> -static inline long cfs_duration_sec(long d)
> -{
> -	return d / msecs_to_jiffies(MSEC_PER_SEC);
> -}
> -
>  static inline int cfs_time_before_64(u64 t1, u64 t2)
>  {
>  	return (__s64)t2 - (__s64)t1 > 0;
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> index d0ce37d72571..959e119384df 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
> @@ -1068,7 +1068,7 @@ static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid,
>  
>  	CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
>  	       libcfs_nid2str(nid), peer,
> -	       last_alive ? cfs_duration_sec(now - last_alive) : -1);
> +	       last_alive ? (now - last_alive) / HZ : -1);
>  }
>  
>  static void kiblnd_free_pages(struct kib_pages *p)
> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> index 563ff5c972bf..b4a182d87ae7 100644
> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
> @@ -3144,7 +3144,7 @@ kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs)
>  		if (time_after_eq(jiffies, tx->tx_deadline)) {
>  			CERROR("Timed out tx: %s, %lu seconds\n",
>  			       kiblnd_queue2str(conn, txs),
> -			       cfs_duration_sec(jiffies - tx->tx_deadline));
> +			       (jiffies - tx->tx_deadline) / HZ);
>  			return 1;
>  		}
>  	}
> @@ -3206,8 +3206,7 @@ kiblnd_check_conns(int idx)
>  			if (timedout) {
>  				CERROR("Timed out RDMA with %s (%lu): c: %u, oc: %u, rc: %u\n",
>  				       libcfs_nid2str(peer->ibp_nid),
> -				       cfs_duration_sec(jiffies -
> -							peer->ibp_last_alive),
> +				       (jiffies - peer->ibp_last_alive) / HZ,
>  				       conn->ibc_credits,
>  				       conn->ibc_outstanding_credits,
>  				       conn->ibc_reserved_credits);
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index 16c1ab0b0bd9..79b98cdd0f9d 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -1682,7 +1682,7 @@ ksocknal_destroy_conn(struct ksock_conn *conn)
>  		       libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type,
>  		       &conn->ksnc_ipaddr, conn->ksnc_port,
>  		       iov_iter_count(&conn->ksnc_rx_to), conn->ksnc_rx_nob_left,
> -		       cfs_duration_sec(jiffies - last_rcv));
> +		       (jiffies - last_rcv) / HZ);
>  		lnet_finalize(conn->ksnc_peer->ksnp_ni,
>  			      conn->ksnc_cookie, -EIO);
>  		break;
> @@ -1870,7 +1870,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
>  
>  	CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago, connect %d\n",
>  	       libcfs_nid2str(nid), peer,
> -	       last_alive ? cfs_duration_sec(now - last_alive) : -1,
> +	       last_alive ? (now - last_alive) / HZ : -1,
>  	       connect);
>  
>  	if (!connect)
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index 8ead1e02e854..14450fd5957a 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -751,7 +751,7 @@ ksocknal_find_connectable_route_locked(struct ksock_peer *peer)
>  			       &route->ksnr_ipaddr,
>  			       route->ksnr_connected,
>  			       route->ksnr_retry_interval,
> -			       cfs_duration_sec(route->ksnr_timeout - now));
> +			       (route->ksnr_timeout - now) / HZ);
>  			continue;
>  		}
>  
> @@ -2439,7 +2439,7 @@ ksocknal_check_peer_timeouts(int idx)
>  
>  		CERROR("Total %d stale ZC_REQs for peer %s detected; the oldest(%p) timed out %ld secs ago, resid: %d, wmem: %d\n",
>  		       n, libcfs_nid2str(peer->ksnp_id.nid), tx_stale,
> -		       cfs_duration_sec(jiffies - deadline),
> +		       (jiffies - deadline) / HZ,
>  		       resid, conn->ksnc_sock->sk->sk_wmem_queued);
>  
>  		ksocknal_close_conn_and_siblings(conn, -ETIMEDOUT);
> diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c
> index 1371224a8cb9..5862f0730dd0 100644
> --- a/drivers/staging/lustre/lnet/libcfs/debug.c
> +++ b/drivers/staging/lustre/lnet/libcfs/debug.c
> @@ -126,7 +126,7 @@ static int param_get_delay(char *buffer, const struct kernel_param *kp)
>  {
>  	unsigned int d = *(unsigned int *)kp->arg;
>  
> -	return sprintf(buffer, "%u", (unsigned int)cfs_duration_sec(d * 100));
> +	return sprintf(buffer, "%u", (unsigned int)(d * 100) / HZ);
>  }
>  
>  unsigned int libcfs_console_max_delay;
> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
> index 8baf35d56ca7..6267d5e4bbd6 100644
> --- a/drivers/staging/lustre/lnet/lnet/router.c
> +++ b/drivers/staging/lustre/lnet/lnet/router.c
> @@ -1752,7 +1752,7 @@ lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when)
>  		CWARN("Ignoring prediction from %s of %s %s %ld seconds in the future\n",
>  		      !ni ? "userspace" : libcfs_nid2str(ni->ni_nid),
>  		      libcfs_nid2str(nid), alive ? "up" : "down",
> -		      cfs_duration_sec(when - now));
> +		      (when - now) / HZ);
>  		return -EINVAL;
>  	}
>  
> diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
> index e4172311be68..015dccbc4a58 100644
> --- a/drivers/staging/lustre/lnet/lnet/router_proc.c
> +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
> @@ -331,7 +331,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
>  			int alive_cnt = peer->lp_alive_count;
>  			int alive = peer->lp_alive;
>  			int pingsent = !peer->lp_ping_notsent;
> -			int last_ping = cfs_duration_sec(now - peer->lp_ping_timestamp);
> +			int last_ping = (now - peer->lp_ping_timestamp) / HZ;
>  			int down_ni = 0;
>  			struct lnet_route *rtr;
>  
> @@ -363,7 +363,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
>  					      nrefs, nrtrrefs, alive_cnt,
>  					      alive ? "up" : "down", last_ping,
>  					      pingsent,
> -					      cfs_duration_sec(deadline - now),
> +					      (deadline - now) / HZ,
>  					      down_ni, libcfs_nid2str(nid));
>  			LASSERT(tmpstr + tmpsiz - s > 0);
>  		}
> @@ -512,7 +512,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
>  				long delta;
>  
>  				delta = now - peer->lp_last_alive;
> -				lastalive = cfs_duration_sec(delta);
> +				lastalive = (delta) / HZ;
>  
>  				/* No need to mess up peers contents with
>  				 * arbitrarily long integers - it suffices to
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index 187095022fb1..f573de9cf45d 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -1181,7 +1181,7 @@ static enum ldlm_policy_res ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
>  
>  	slv = ldlm_pool_get_slv(pl);
>  	lvf = ldlm_pool_get_lvf(pl);
> -	la = cfs_duration_sec(cur - lock->l_last_used);
> +	la = (cur - lock->l_last_used) / HZ;
>  	lv = lvf * la * unused;
>  
>  	/* Inform pool about current CLV to see it via debugfs. */
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 19:03     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:03 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> This wrapper is only used once, so open-code it as max().
> 
> This allows us to remove the libcfs_time.h include file.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/libcfs/libcfs.h   |    1 
>  .../lustre/include/linux/libcfs/libcfs_time.h      |   50 --------------------
>  .../lustre/include/linux/libcfs/linux/linux-time.h |    2 -
>  drivers/staging/lustre/lustre/ptlrpc/import.c      |    4 +-
>  4 files changed, 3 insertions(+), 54 deletions(-)
>  delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> index 3b751c436b3d..3d3fa52858e5 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> @@ -43,7 +43,6 @@
>  #include <linux/libcfs/libcfs_private.h>
>  #include <linux/libcfs/libcfs_cpu.h>
>  #include <linux/libcfs/libcfs_prim.h>
> -#include <linux/libcfs/libcfs_time.h>
>  #include <linux/libcfs/libcfs_string.h>
>  #include <linux/libcfs/libcfs_hash.h>
>  #include <linux/libcfs/libcfs_fail.h>
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> deleted file mode 100644
> index 172a8872e3f3..000000000000
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ /dev/null
> @@ -1,50 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * GPL HEADER START
> - *
> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 only,
> - * as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * General Public License version 2 for more details (a copy is included
> - * in the LICENSE file that accompanied this code).
> - *
> - * You should have received a copy of the GNU General Public License
> - * version 2 along with this program; If not, see
> - * http://www.gnu.org/licenses/gpl-2.0.html
> - *
> - * GPL HEADER END
> - */
> -/*
> - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
> - * Use is subject to license terms.
> - */
> -/*
> - * This file is part of Lustre, http://www.lustre.org/
> - * Lustre is a trademark of Sun Microsystems, Inc.
> - *
> - * libcfs/include/libcfs/libcfs_time.h
> - *
> - * Time functions.
> - *
> - */
> -
> -#ifndef __LIBCFS_TIME_H__
> -#define __LIBCFS_TIME_H__
> -/*
> - * return valid time-out based on user supplied one. Currently we only check
> - * that time-out is not shorted than allowed.
> - */
> -static inline long cfs_timeout_cap(long timeout)
> -{
> -	if (timeout < CFS_TICK)
> -		timeout = CFS_TICK;
> -	return timeout;
> -}
> -
> -#endif
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index ff3aae2f1231..ecb2126a9e6f 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
>  /*
>   * One jiffy
>   */
> -#define CFS_TICK		(1)
> +#define CFS_TICK		(1UL)
>  
>  #define CFS_DURATION_T	  "%ld"
>  
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index 4a9d1f189d01..dd4fd54128dd 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
>  	}
>  
>  	if (ptlrpc_import_in_recovery(imp)) {
> -		long timeout;
> +		unsigned long timeout;
>  
>  		if (AT_OFF) {
>  			if (imp->imp_server_timeout)
> @@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
>  
>  		if (wait_event_idle_timeout(imp->imp_recovery_waitq,
>  					    !ptlrpc_import_in_recovery(imp),
> -					    cfs_timeout_cap(timeout)) == 0)
> +					    max(timeout, CFS_TICK)) == 0)
>  			l_wait_event_abortable(
>  				imp->imp_recovery_waitq,
>  				!ptlrpc_import_in_recovery(imp));
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()
@ 2018-03-30 19:03     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:03 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> This wrapper is only used once, so open-code it as max().
> 
> This allows us to remove the libcfs_time.h include file.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/libcfs/libcfs.h   |    1 
>  .../lustre/include/linux/libcfs/libcfs_time.h      |   50 --------------------
>  .../lustre/include/linux/libcfs/linux/linux-time.h |    2 -
>  drivers/staging/lustre/lustre/ptlrpc/import.c      |    4 +-
>  4 files changed, 3 insertions(+), 54 deletions(-)
>  delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> index 3b751c436b3d..3d3fa52858e5 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> @@ -43,7 +43,6 @@
>  #include <linux/libcfs/libcfs_private.h>
>  #include <linux/libcfs/libcfs_cpu.h>
>  #include <linux/libcfs/libcfs_prim.h>
> -#include <linux/libcfs/libcfs_time.h>
>  #include <linux/libcfs/libcfs_string.h>
>  #include <linux/libcfs/libcfs_hash.h>
>  #include <linux/libcfs/libcfs_fail.h>
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> deleted file mode 100644
> index 172a8872e3f3..000000000000
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ /dev/null
> @@ -1,50 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * GPL HEADER START
> - *
> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 only,
> - * as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * General Public License version 2 for more details (a copy is included
> - * in the LICENSE file that accompanied this code).
> - *
> - * You should have received a copy of the GNU General Public License
> - * version 2 along with this program; If not, see
> - * http://www.gnu.org/licenses/gpl-2.0.html
> - *
> - * GPL HEADER END
> - */
> -/*
> - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
> - * Use is subject to license terms.
> - */
> -/*
> - * This file is part of Lustre, http://www.lustre.org/
> - * Lustre is a trademark of Sun Microsystems, Inc.
> - *
> - * libcfs/include/libcfs/libcfs_time.h
> - *
> - * Time functions.
> - *
> - */
> -
> -#ifndef __LIBCFS_TIME_H__
> -#define __LIBCFS_TIME_H__
> -/*
> - * return valid time-out based on user supplied one. Currently we only check
> - * that time-out is not shorted than allowed.
> - */
> -static inline long cfs_timeout_cap(long timeout)
> -{
> -	if (timeout < CFS_TICK)
> -		timeout = CFS_TICK;
> -	return timeout;
> -}
> -
> -#endif
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index ff3aae2f1231..ecb2126a9e6f 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
>  /*
>   * One jiffy
>   */
> -#define CFS_TICK		(1)
> +#define CFS_TICK		(1UL)
>  
>  #define CFS_DURATION_T	  "%ld"
>  
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index 4a9d1f189d01..dd4fd54128dd 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
>  	}
>  
>  	if (ptlrpc_import_in_recovery(imp)) {
> -		long timeout;
> +		unsigned long timeout;
>  
>  		if (AT_OFF) {
>  			if (imp->imp_server_timeout)
> @@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
>  
>  		if (wait_event_idle_timeout(imp->imp_recovery_waitq,
>  					    !ptlrpc_import_in_recovery(imp),
> -					    cfs_timeout_cap(timeout)) == 0)
> +					    max(timeout, CFS_TICK)) == 0)
>  			l_wait_event_abortable(
>  				imp->imp_recovery_waitq,
>  				!ptlrpc_import_in_recovery(imp));
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 15/17] staging: lustre: discard cfs_time_before_64()
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 19:03     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:03 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> cfs_time_before_64 is the same as time_before64()
> similarly cfs_time_beforeq_64() matsches time_before_eq64()
> So just use the standard interfaces.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/linux/linux-time.h |   14 --------------
>  drivers/staging/lustre/lustre/include/obd_class.h  |    4 ++--
>  drivers/staging/lustre/lustre/ptlrpc/import.c      |    4 ++--
>  3 files changed, 4 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index 9a353c6cb85a..ecdebccf2b44 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -56,20 +56,6 @@
>  
>  #include <linux/jiffies.h>
>  
> -/*
> - * Generic kernel stuff
> - */
> -
> -static inline int cfs_time_before_64(u64 t1, u64 t2)
> -{
> -	return (__s64)t2 - (__s64)t1 > 0;
> -}
> -
> -static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
> -{
> -	return (__s64)t2 - (__s64)t1 >= 0;
> -}
> -
>  /*
>   * One jiffy
>   */
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> index 7cfc3c8d100c..176b63e2c9a7 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -932,7 +932,7 @@ static inline int obd_statfs_async(struct obd_export *exp,
>  
>  	CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n",
>  	       obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age);
> -	if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
> +	if (time_before64(obd->obd_osfs_age, max_age)) {
>  		rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
>  	} else {
>  		CDEBUG(D_SUPER,
> @@ -992,7 +992,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
>  
>  	CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n",
>  	       obd->obd_osfs_age, max_age);
> -	if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
> +	if (time_before64(obd->obd_osfs_age, max_age)) {
>  		rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
>  		if (rc == 0) {
>  			spin_lock(&obd->obd_osfs_lock);
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index dd4fd54128dd..537a9e2ed467 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -463,7 +463,7 @@ static int import_select_connection(struct obd_import *imp)
>  		 * the last successful attempt, go with this one
>  		 */
>  		if ((conn->oic_last_attempt == 0) ||
> -		    cfs_time_beforeq_64(conn->oic_last_attempt,
> +		    time_before_eq64(conn->oic_last_attempt,
>  					imp->imp_last_success_conn)) {
>  			imp_conn = conn;
>  			tried_all = 0;
> @@ -476,7 +476,7 @@ static int import_select_connection(struct obd_import *imp)
>  		 */
>  		if (!imp_conn)
>  			imp_conn = conn;
> -		else if (cfs_time_before_64(conn->oic_last_attempt,
> +		else if (time_before64(conn->oic_last_attempt,
>  					    imp_conn->oic_last_attempt))
>  			imp_conn = conn;
>  	}
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 15/17] staging: lustre: discard cfs_time_before_64()
@ 2018-03-30 19:03     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:03 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> cfs_time_before_64 is the same as time_before64()
> similarly cfs_time_beforeq_64() matsches time_before_eq64()
> So just use the standard interfaces.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/include/linux/libcfs/linux/linux-time.h |   14 --------------
>  drivers/staging/lustre/lustre/include/obd_class.h  |    4 ++--
>  drivers/staging/lustre/lustre/ptlrpc/import.c      |    4 ++--
>  3 files changed, 4 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index 9a353c6cb85a..ecdebccf2b44 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -56,20 +56,6 @@
>  
>  #include <linux/jiffies.h>
>  
> -/*
> - * Generic kernel stuff
> - */
> -
> -static inline int cfs_time_before_64(u64 t1, u64 t2)
> -{
> -	return (__s64)t2 - (__s64)t1 > 0;
> -}
> -
> -static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
> -{
> -	return (__s64)t2 - (__s64)t1 >= 0;
> -}
> -
>  /*
>   * One jiffy
>   */
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> index 7cfc3c8d100c..176b63e2c9a7 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -932,7 +932,7 @@ static inline int obd_statfs_async(struct obd_export *exp,
>  
>  	CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n",
>  	       obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age);
> -	if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
> +	if (time_before64(obd->obd_osfs_age, max_age)) {
>  		rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
>  	} else {
>  		CDEBUG(D_SUPER,
> @@ -992,7 +992,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
>  
>  	CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n",
>  	       obd->obd_osfs_age, max_age);
> -	if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
> +	if (time_before64(obd->obd_osfs_age, max_age)) {
>  		rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
>  		if (rc == 0) {
>  			spin_lock(&obd->obd_osfs_lock);
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index dd4fd54128dd..537a9e2ed467 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -463,7 +463,7 @@ static int import_select_connection(struct obd_import *imp)
>  		 * the last successful attempt, go with this one
>  		 */
>  		if ((conn->oic_last_attempt == 0) ||
> -		    cfs_time_beforeq_64(conn->oic_last_attempt,
> +		    time_before_eq64(conn->oic_last_attempt,
>  					imp->imp_last_success_conn)) {
>  			imp_conn = conn;
>  			tried_all = 0;
> @@ -476,7 +476,7 @@ static int import_select_connection(struct obd_import *imp)
>  		 */
>  		if (!imp_conn)
>  			imp_conn = conn;
> -		else if (cfs_time_before_64(conn->oic_last_attempt,
> +		else if (time_before64(conn->oic_last_attempt,
>  					    imp_conn->oic_last_attempt))
>  			imp_conn = conn;
>  	}
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 16/17] staging: lustre: discard linux-time.h
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 19:03     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:03 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> Very little is left in linux-time.h.
> Move CFS_TICK to libcfs.h discard the test.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/libcfs/libcfs.h   |    5 ++
>  .../lustre/include/linux/libcfs/linux/libcfs.h     |    1 
>  .../lustre/include/linux/libcfs/linux/linux-time.h |   66 --------------------
>  drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    2 -
>  4 files changed, 6 insertions(+), 68 deletions(-)
>  delete mode 100644 drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> index 3d3fa52858e5..f183f31da387 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> @@ -52,6 +52,11 @@
>  
>  #define LOWEST_BIT_SET(x)       ((x) & ~((x) - 1))
>  
> +/*
> + * One jiffy
> + */
> +#define CFS_TICK		(1UL)
> +
>  /*
>   * Lustre Error Checksum: calculates checksum
>   * of Hex number by XORing each bit.
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> index 30e333af8d0d..c39c34d74382 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> @@ -80,7 +80,6 @@
>  #include <linux/uaccess.h>
>  #include <stdarg.h>
>  #include "linux-cpu.h"
> -#include "linux-time.h"
>  
>  #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
>  
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> deleted file mode 100644
> index ecdebccf2b44..000000000000
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ /dev/null
> @@ -1,66 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * GPL HEADER START
> - *
> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 only,
> - * as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * General Public License version 2 for more details (a copy is included
> - * in the LICENSE file that accompanied this code).
> - *
> - * You should have received a copy of the GNU General Public License
> - * version 2 along with this program; If not, see
> - * http://www.gnu.org/licenses/gpl-2.0.html
> - *
> - * GPL HEADER END
> - */
> -/*
> - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
> - * Use is subject to license terms.
> - */
> -/*
> - * This file is part of Lustre, http://www.lustre.org/
> - * Lustre is a trademark of Sun Microsystems, Inc.
> - *
> - * libcfs/include/libcfs/linux/linux-time.h
> - *
> - * Implementation of portable time API for Linux (kernel and user-level).
> - *
> - * Author: Nikita Danilov <nikita@clusterfs.com>
> - */
> -
> -#ifndef __LIBCFS_LINUX_LINUX_TIME_H__
> -#define __LIBCFS_LINUX_LINUX_TIME_H__
> -
> -#ifndef __LIBCFS_LIBCFS_H__
> -#error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
> -#endif
> -
> -#define ONE_BILLION ((u_int64_t)1000000000)
> -#define ONE_MILLION 1000000
> -
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> -#include <linux/time.h>
> -#include <asm/div64.h>
> -
> -/*
> - * post 2.5 kernels.
> - */
> -
> -#include <linux/jiffies.h>
> -
> -/*
> - * One jiffy
> - */
> -#define CFS_TICK		(1UL)
> -
> -#define CFS_DURATION_T	  "%ld"
> -
> -#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> index 3f17c673d1b8..89eef8ec7df4 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> @@ -251,7 +251,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
>  		 * we will SKIP the next ping at next_ping, and the
>  		 * ping will get sent 2 timeouts from now!  Beware.
>  		 */
> -		CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
> +		CDEBUG(D_INFO, "next wakeup in %ld (%ld)\n",
>  		       time_to_next_wake,
>  		       this_ping + PING_INTERVAL * HZ);
>  	} while (time_to_next_wake <= 0);
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 16/17] staging: lustre: discard linux-time.h
@ 2018-03-30 19:03     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:03 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> Very little is left in linux-time.h.
> Move CFS_TICK to libcfs.h discard the test.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/libcfs/libcfs.h   |    5 ++
>  .../lustre/include/linux/libcfs/linux/libcfs.h     |    1 
>  .../lustre/include/linux/libcfs/linux/linux-time.h |   66 --------------------
>  drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    2 -
>  4 files changed, 6 insertions(+), 68 deletions(-)
>  delete mode 100644 drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> index 3d3fa52858e5..f183f31da387 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> @@ -52,6 +52,11 @@
>  
>  #define LOWEST_BIT_SET(x)       ((x) & ~((x) - 1))
>  
> +/*
> + * One jiffy
> + */
> +#define CFS_TICK		(1UL)
> +
>  /*
>   * Lustre Error Checksum: calculates checksum
>   * of Hex number by XORing each bit.
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> index 30e333af8d0d..c39c34d74382 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> @@ -80,7 +80,6 @@
>  #include <linux/uaccess.h>
>  #include <stdarg.h>
>  #include "linux-cpu.h"
> -#include "linux-time.h"
>  
>  #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
>  
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> deleted file mode 100644
> index ecdebccf2b44..000000000000
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ /dev/null
> @@ -1,66 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * GPL HEADER START
> - *
> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 only,
> - * as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * General Public License version 2 for more details (a copy is included
> - * in the LICENSE file that accompanied this code).
> - *
> - * You should have received a copy of the GNU General Public License
> - * version 2 along with this program; If not, see
> - * http://www.gnu.org/licenses/gpl-2.0.html
> - *
> - * GPL HEADER END
> - */
> -/*
> - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
> - * Use is subject to license terms.
> - */
> -/*
> - * This file is part of Lustre, http://www.lustre.org/
> - * Lustre is a trademark of Sun Microsystems, Inc.
> - *
> - * libcfs/include/libcfs/linux/linux-time.h
> - *
> - * Implementation of portable time API for Linux (kernel and user-level).
> - *
> - * Author: Nikita Danilov <nikita@clusterfs.com>
> - */
> -
> -#ifndef __LIBCFS_LINUX_LINUX_TIME_H__
> -#define __LIBCFS_LINUX_LINUX_TIME_H__
> -
> -#ifndef __LIBCFS_LIBCFS_H__
> -#error Do not #include this file directly. #include <linux/libcfs/libcfs.h> instead
> -#endif
> -
> -#define ONE_BILLION ((u_int64_t)1000000000)
> -#define ONE_MILLION 1000000
> -
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> -#include <linux/time.h>
> -#include <asm/div64.h>
> -
> -/*
> - * post 2.5 kernels.
> - */
> -
> -#include <linux/jiffies.h>
> -
> -/*
> - * One jiffy
> - */
> -#define CFS_TICK		(1UL)
> -
> -#define CFS_DURATION_T	  "%ld"
> -
> -#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> index 3f17c673d1b8..89eef8ec7df4 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
> @@ -251,7 +251,7 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
>  		 * we will SKIP the next ping at next_ping, and the
>  		 * ping will get sent 2 timeouts from now!  Beware.
>  		 */
> -		CDEBUG(D_INFO, "next wakeup in " CFS_DURATION_T " (%ld)\n",
> +		CDEBUG(D_INFO, "next wakeup in %ld (%ld)\n",
>  		       time_to_next_wake,
>  		       this_ping + PING_INTERVAL * HZ);
>  	} while (time_to_next_wake <= 0);
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 17/17] staging: lustre: remove cruft from libcfs/linux/libcfs.h
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 19:07     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:07 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> These defines are unused or nearly unused, and do not
> help at all.

Reviewed-by: James Simmons <jsimmons@infradead.org>

> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/libcfs/curproc.h  |    2 --
>  .../lustre/include/linux/libcfs/linux/libcfs.h     |   17 -----------------
>  drivers/staging/lustre/lnet/libcfs/tracefile.c     |    2 +-
>  3 files changed, 1 insertion(+), 20 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h
> index 4702956805a6..d6e4f47b5daf 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
> @@ -43,8 +43,6 @@
>  /*
>   * Plus, platform-specific constant
>   *
> - * CFS_CURPROC_COMM_MAX,
> - *
>   * and opaque scalar type
>   *
>   * kernel_cap_t
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> index c39c34d74382..0dbd01617865 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> @@ -81,8 +81,6 @@
>  #include <stdarg.h>
>  #include "linux-cpu.h"
>  
> -#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
> -
>  #if !defined(__x86_64__)
>  # ifdef __ia64__
>  #  define CDEBUG_STACK() (THREAD_SIZE -				 \
> @@ -114,19 +112,4 @@ do {								    \
>  #define CDEBUG_STACK() (0L)
>  #endif /* __x86_64__ */
>  
> -#define __current_nesting_level() (0)
> -
> -/**
> - * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
> - *
> - * Implementation is in linux-curproc.c
> - */
> -#define CFS_CURPROC_COMM_MAX (sizeof((struct task_struct *)0)->comm)
> -
> -#include <linux/capability.h>
> -
> -#ifndef WITH_WATCHDOG
> -#define WITH_WATCHDOG
> -#endif
> -
>  #endif /* _LINUX_LIBCFS_H */
> diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> index 129430e74d00..514e1845740e 100644
> --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
> +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> @@ -328,7 +328,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  		goto console;
>  	}
>  
> -	depth = __current_nesting_level();
> +	depth = 0;
>  	known_size = strlen(file) + 1 + depth;
>  	if (msgdata->msg_fn)
>  		known_size += strlen(msgdata->msg_fn) + 1;
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 17/17] staging: lustre: remove cruft from libcfs/linux/libcfs.h
@ 2018-03-30 19:07     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:07 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> These defines are unused or nearly unused, and do not
> help at all.

Reviewed-by: James Simmons <jsimmons@infradead.org>

> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/libcfs/curproc.h  |    2 --
>  .../lustre/include/linux/libcfs/linux/libcfs.h     |   17 -----------------
>  drivers/staging/lustre/lnet/libcfs/tracefile.c     |    2 +-
>  3 files changed, 1 insertion(+), 20 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h
> index 4702956805a6..d6e4f47b5daf 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/curproc.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h
> @@ -43,8 +43,6 @@
>  /*
>   * Plus, platform-specific constant
>   *
> - * CFS_CURPROC_COMM_MAX,
> - *
>   * and opaque scalar type
>   *
>   * kernel_cap_t
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> index c39c34d74382..0dbd01617865 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
> @@ -81,8 +81,6 @@
>  #include <stdarg.h>
>  #include "linux-cpu.h"
>  
> -#define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
> -
>  #if !defined(__x86_64__)
>  # ifdef __ia64__
>  #  define CDEBUG_STACK() (THREAD_SIZE -				 \
> @@ -114,19 +112,4 @@ do {								    \
>  #define CDEBUG_STACK() (0L)
>  #endif /* __x86_64__ */
>  
> -#define __current_nesting_level() (0)
> -
> -/**
> - * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
> - *
> - * Implementation is in linux-curproc.c
> - */
> -#define CFS_CURPROC_COMM_MAX (sizeof((struct task_struct *)0)->comm)
> -
> -#include <linux/capability.h>
> -
> -#ifndef WITH_WATCHDOG
> -#define WITH_WATCHDOG
> -#endif
> -
>  #endif /* _LINUX_LIBCFS_H */
> diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> index 129430e74d00..514e1845740e 100644
> --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
> +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> @@ -328,7 +328,7 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
>  		goto console;
>  	}
>  
> -	depth = __current_nesting_level();
> +	depth = 0;
>  	known_size = strlen(file) + 1 + depth;
>  	if (msgdata->msg_fn)
>  		known_size += strlen(msgdata->msg_fn) + 1;
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 03/17] staging: lustre: LNET excludes USERIO
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-03-30 19:09     ` James Simmons
  -1 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:09 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> LNET_MINOR and USERIO_MINOR are the same value, so
> they cannot both be used in the same kernel.
> Until this is resolved, don't allow them to be built
> together.  This saves automatic testing from noticing this
> known problem.

Nak. I have the proper fix for this. Will push right away.
 
> Reported-by: kernel test robot <fengguang.wu@intel.com>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lnet/Kconfig |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lnet/Kconfig b/drivers/staging/lustre/lnet/Kconfig
> index ad049e6f24e4..fe4b24acf075 100644
> --- a/drivers/staging/lustre/lnet/Kconfig
> +++ b/drivers/staging/lustre/lnet/Kconfig
> @@ -1,6 +1,6 @@
>  config LNET
>  	tristate "Lustre networking subsystem (LNet)"
> -	depends on INET
> +	depends on INET && !USERIO
>  	help
>  	  The Lustre network layer, also known as LNet, is a networking abstaction
>  	  level API that was initially created to allow Lustre Filesystem to utilize
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 03/17] staging: lustre: LNET excludes USERIO
@ 2018-03-30 19:09     ` James Simmons
  0 siblings, 0 replies; 86+ messages in thread
From: James Simmons @ 2018-03-30 19:09 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Greg Kroah-Hartman, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List


> LNET_MINOR and USERIO_MINOR are the same value, so
> they cannot both be used in the same kernel.
> Until this is resolved, don't allow them to be built
> together.  This saves automatic testing from noticing this
> known problem.

Nak. I have the proper fix for this. Will push right away.
 
> Reported-by: kernel test robot <fengguang.wu@intel.com>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lnet/Kconfig |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lnet/Kconfig b/drivers/staging/lustre/lnet/Kconfig
> index ad049e6f24e4..fe4b24acf075 100644
> --- a/drivers/staging/lustre/lnet/Kconfig
> +++ b/drivers/staging/lustre/lnet/Kconfig
> @@ -1,6 +1,6 @@
>  config LNET
>  	tristate "Lustre networking subsystem (LNet)"
> -	depends on INET
> +	depends on INET && !USERIO
>  	help
>  	  The Lustre network layer, also known as LNet, is a networking abstaction
>  	  level API that was initially created to allow Lustre Filesystem to utilize
> 
> 
> 

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
  2018-03-30 19:02     ` [lustre-devel] " James Simmons
@ 2018-04-02 19:34       ` Dilger, Andreas
  -1 siblings, 0 replies; 86+ messages in thread
From: Dilger, Andreas @ 2018-04-02 19:34 UTC (permalink / raw)
  To: James Simmons
  Cc: NeilBrown, Drokin, Oleg, Greg Kroah-Hartman,
	Linux Kernel Mailing List, Lustre Development List


> On Mar 30, 2018, at 13:02, James Simmons <jsimmons@infradead.org> wrote:
> 
> 
>> This function simply multiplies by HZ and adds jiffies.
>> This is simple enough to be opencoded, and doing so
>> makes the code easier to read.
>> 
>> Same for cfs_time_shift_64()
> 
> Reviewed-by: James Simmons <jsimmons@infradead.org>

Hmm, I thought we were trying to get rid of direct HZ usage in modules,
because of tickless systems, and move to e.g. msecs_to_jiffies() or similar?

Cheers, Andreas

> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>> .../lustre/include/linux/libcfs/libcfs_time.h      |    5 ----
>> .../lustre/include/linux/libcfs/linux/linux-time.h |    5 ----
>> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   12 +++++----
>> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    4 ++-
>> .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 ++-
>> .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   12 +++++----
>> drivers/staging/lustre/lnet/lnet/net_fault.c       |   26 ++++++++++----------
>> drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
>> drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    2 +-
>> drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 +-
>> drivers/staging/lustre/lustre/llite/llite_lib.c    |    4 ++-
>> drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +++++----
>> drivers/staging/lustre/lustre/llite/statahead.c    |    2 +-
>> drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    2 +-
>> drivers/staging/lustre/lustre/lov/lov_obd.c        |    2 +-
>> drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 +-
>> .../lustre/lustre/obdclass/lprocfs_status.c        |   12 +++++----
>> .../staging/lustre/lustre/obdclass/obd_config.c    |    2 +-
>> drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +-
>> drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    6 ++---
>> drivers/staging/lustre/lustre/ptlrpc/service.c     |    2 +-
>> 21 files changed, 56 insertions(+), 66 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
>> index 7b41a129f041..0ebbde4ec8e8 100644
>> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
>> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
>> @@ -50,11 +50,6 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
>> 	return time_before_eq(t2, t1);
>> }
>> 
>> -static inline unsigned long cfs_time_shift(int seconds)
>> -{
>> -	return jiffies + seconds * HZ;
>> -}
>> -
>> /*
>>  * return valid time-out based on user supplied one. Currently we only check
>>  * that time-out is not shorted than allowed.
>> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> index b3a80531bd71..ff3aae2f1231 100644
>> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> @@ -65,11 +65,6 @@ static inline long cfs_duration_sec(long d)
>> 	return d / msecs_to_jiffies(MSEC_PER_SEC);
>> }
>> 
>> -static inline u64 cfs_time_shift_64(int seconds)
>> -{
>> -	return get_jiffies_64() + (u64)seconds * HZ;
>> -}
>> -
>> static inline int cfs_time_before_64(u64 t1, u64 t2)
>> {
>> 	return (__s64)t2 - (__s64)t1 > 0;
>> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
>> index 7df07f39b849..276bf486f64b 100644
>> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
>> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
>> @@ -1446,7 +1446,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps,
>> 	if (rc)
>> 		goto out_fpo;
>> 
>> -	fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
>> +	fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>> 	fpo->fpo_owner = fps;
>> 	*pp_fpo = fpo;
>> 
>> @@ -1619,7 +1619,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
>> 	spin_lock(&fps->fps_lock);
>> 	version = fps->fps_version;
>> 	list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
>> -		fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
>> +		fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>> 		fpo->fpo_map_count++;
>> 
>> 		if (fpo->fpo_is_fmr) {
>> @@ -1743,7 +1743,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
>> 		fps->fps_version++;
>> 		list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
>> 	} else {
>> -		fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
>> +		fps->fps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
>> 	}
>> 	spin_unlock(&fps->fps_lock);
>> 
>> @@ -1764,7 +1764,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, struct kib_pool *pool, int
>> 
>> 	memset(pool, 0, sizeof(*pool));
>> 	INIT_LIST_HEAD(&pool->po_free_list);
>> -	pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
>> +	pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>> 	pool->po_owner    = ps;
>> 	pool->po_size     = size;
>> }
>> @@ -1899,7 +1899,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>> 			continue;
>> 
>> 		pool->po_allocated++;
>> -		pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
>> +		pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>> 		node = pool->po_free_list.next;
>> 		list_del(node);
>> 
>> @@ -1947,7 +1947,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>> 	if (!rc) {
>> 		list_add_tail(&pool->po_list, &ps->ps_pool_list);
>> 	} else {
>> -		ps->ps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
>> +		ps->ps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
>> 		CERROR("Can't allocate new %s pool because out of memory\n",
>> 		       ps->ps_name);
>> 	}
>> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
>> index c1c3277f4c1f..f9761d8f2e3e 100644
>> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
>> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
>> @@ -3700,13 +3700,13 @@ kiblnd_failover_thread(void *arg)
>> 			LASSERT(dev->ibd_failover);
>> 			dev->ibd_failover = 0;
>> 			if (rc >= 0) { /* Device is OK or failover succeed */
>> -				dev->ibd_next_failover = cfs_time_shift(3);
>> +				dev->ibd_next_failover = jiffies + 3 * HZ;
>> 				continue;
>> 			}
>> 
>> 			/* failed to failover, retry later */
>> 			dev->ibd_next_failover =
>> -				cfs_time_shift(min(dev->ibd_failed_failover, 10));
>> +				jiffies + min(dev->ibd_failed_failover, 10) * HZ;
>> 			if (kiblnd_dev_can_failover(dev)) {
>> 				list_add_tail(&dev->ibd_fail_list,
>> 					      &kiblnd_data.kib_failed_devs);
>> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
>> index 4546618c1c12..16c1ab0b0bd9 100644
>> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
>> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
>> @@ -1287,7 +1287,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
>> 	conn->ksnc_tx_last_post = jiffies;
>> 	/* Set the deadline for the outgoing HELLO to drain */
>> 	conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
>> -	conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +	conn->ksnc_tx_deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 	mb();   /* order with adding to peer's conn list */
>> 
>> 	list_add(&conn->ksnc_list, &peer->ksnp_conns);
>> @@ -1852,7 +1852,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
>> 			if (bufnob < conn->ksnc_tx_bufnob) {
>> 				/* something got ACKed */
>> 				conn->ksnc_tx_deadline =
>> -					cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +					jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 				peer->ksnp_last_alive = now;
>> 				conn->ksnc_tx_bufnob = bufnob;
>> 			}
>> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
>> index 5b34c7c030ad..1ace54c9b133 100644
>> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
>> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
>> @@ -221,7 +221,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>> 			 * something got ACKed
>> 			 */
>> 			conn->ksnc_tx_deadline =
>> -				cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +				jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 			conn->ksnc_peer->ksnp_last_alive = jiffies;
>> 			conn->ksnc_tx_bufnob = bufnob;
>> 			mb();
>> @@ -269,7 +269,7 @@ ksocknal_recv_iter(struct ksock_conn *conn)
>> 
>> 	conn->ksnc_peer->ksnp_last_alive = jiffies;
>> 	conn->ksnc_rx_deadline =
>> -		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 	mb();		       /* order with setting rx_started */
>> 	conn->ksnc_rx_started = 1;
>> 
>> @@ -405,7 +405,7 @@ ksocknal_check_zc_req(struct ksock_tx *tx)
>> 
>> 	/* ZC_REQ is going to be pinned to the peer */
>> 	tx->tx_deadline =
>> -		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 
>> 	LASSERT(!tx->tx_msg.ksm_zc_cookies[0]);
>> 
>> @@ -677,7 +677,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
>> 	if (list_empty(&conn->ksnc_tx_queue) && !bufnob) {
>> 		/* First packet starts the timeout */
>> 		conn->ksnc_tx_deadline =
>> -			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 		if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
>> 			conn->ksnc_peer->ksnp_last_alive = jiffies;
>> 		conn->ksnc_tx_bufnob = 0;
>> @@ -858,7 +858,7 @@ ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
>> 	    ksocknal_find_connecting_route_locked(peer)) {
>> 		/* the message is going to be pinned to the peer */
>> 		tx->tx_deadline =
>> -			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 
>> 		/* Queue the message until a connection is established */
>> 		list_add_tail(&tx->tx_list, &peer->ksnp_tx_queue);
>> @@ -2308,7 +2308,7 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
>> 	 * retry 10 secs later, so we wouldn't put pressure
>> 	 * on this peer if we failed to send keepalive this time
>> 	 */
>> -	peer->ksnp_send_keepalive = cfs_time_shift(10);
>> +	peer->ksnp_send_keepalive = jiffies + 10 * HZ;
>> 
>> 	conn = ksocknal_find_conn_locked(peer, NULL, 1);
>> 	if (conn) {
>> diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
>> index 3928e9a74d6f..05d7b754815a 100644
>> --- a/drivers/staging/lustre/lnet/lnet/net_fault.c
>> +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
>> @@ -169,9 +169,9 @@ lnet_drop_rule_add(struct lnet_fault_attr *attr)
>> 
>> 	rule->dr_attr = *attr;
>> 	if (attr->u.drop.da_interval) {
>> -		rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
>> -		rule->dr_drop_time = cfs_time_shift(
>> -			prandom_u32_max(attr->u.drop.da_interval));
>> +		rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
>> +		rule->dr_drop_time = jiffies +
>> +			prandom_u32_max(attr->u.drop.da_interval) * HZ;
>> 	} else {
>> 		rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
>> 	}
>> @@ -279,9 +279,9 @@ lnet_drop_rule_reset(void)
>> 		if (attr->u.drop.da_rate) {
>> 			rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
>> 		} else {
>> -			rule->dr_drop_time = cfs_time_shift(
>> -				prandom_u32_max(attr->u.drop.da_interval));
>> -			rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
>> +			rule->dr_drop_time = jiffies +
>> +				prandom_u32_max(attr->u.drop.da_interval) * HZ;
>> +			rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
>> 		}
>> 		spin_unlock(&rule->dr_lock);
>> 	}
>> @@ -513,7 +513,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
>> 
>> 	list_add_tail(&msg->msg_list, &rule->dl_msg_list);
>> 	msg->msg_delay_send = round_timeout(
>> -			cfs_time_shift(attr->u.delay.la_latency));
>> +			jiffies + attr->u.delay.la_latency * HZ);
>> 	if (rule->dl_msg_send == -1) {
>> 		rule->dl_msg_send = msg->msg_delay_send;
>> 		mod_timer(&rule->dl_timer, rule->dl_msg_send);
>> @@ -767,9 +767,9 @@ lnet_delay_rule_add(struct lnet_fault_attr *attr)
>> 
>> 	rule->dl_attr = *attr;
>> 	if (attr->u.delay.la_interval) {
>> -		rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
>> -		rule->dl_delay_time = cfs_time_shift(
>> -			prandom_u32_max(attr->u.delay.la_interval));
>> +		rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
>> +		rule->dl_delay_time = jiffies + 
>> +			prandom_u32_max(attr->u.delay.la_interval) * HZ;
>> 	} else {
>> 		rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
>> 	}
>> @@ -920,9 +920,9 @@ lnet_delay_rule_reset(void)
>> 			rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
>> 		} else {
>> 			rule->dl_delay_time =
>> -				cfs_time_shift(prandom_u32_max(
>> -						       attr->u.delay.la_interval));
>> -			rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
>> +				jiffies + prandom_u32_max(
>> +					attr->u.delay.la_interval) * HZ;
>> +			rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
>> 		}
>> 		spin_unlock(&rule->dl_lock);
>> 	}
>> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
>> index 4595a7ad4336..c72d4f4454ec 100644
>> --- a/drivers/staging/lustre/lnet/lnet/router.c
>> +++ b/drivers/staging/lustre/lnet/lnet/router.c
>> @@ -1026,7 +1026,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
>> 
>> 		if (!rtr->lp_ping_deadline) {
>> 			rtr->lp_ping_deadline =
>> -				cfs_time_shift(router_ping_timeout);
>> +				jiffies + router_ping_timeout * HZ;
>> 		}
>> 
>> 		lnet_net_unlock(rtr->lp_cpt);
>> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
>> index 6eb42f16040d..647e85b16c02 100644
>> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
>> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
>> @@ -118,7 +118,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
>> 				 lock->l_last_activity));
>> 		if (cfs_time_after(jiffies, next_dump)) {
>> 			last_dump = next_dump;
>> -			next_dump = cfs_time_shift(300);
>> +			next_dump = jiffies + 300 * HZ;
>> 			ldlm_namespace_dump(D_DLMTRACE,
>> 					    ldlm_lock_to_ns(lock));
>> 			if (last_dump == 0)
>> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
>> index ccd0c082e39b..6c615b6e9bdc 100644
>> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
>> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
>> @@ -1323,7 +1323,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
>> 				 ldlm_res_hash_dump,
>> 				 (void *)(unsigned long)level, 0);
>> 	spin_lock(&ns->ns_lock);
>> -	ns->ns_next_dump = cfs_time_shift(10);
>> +	ns->ns_next_dump = jiffies + 10 * HZ;
>> 	spin_unlock(&ns->ns_lock);
>> }
>> 
>> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
>> index e7500c53fafc..60dbe888e336 100644
>> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
>> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
>> @@ -257,7 +257,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
>> 	 * available
>> 	 */
>> 	err = obd_statfs(NULL, sbi->ll_md_exp, osfs,
>> -			 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			 get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			 OBD_STATFS_FOR_MDT0);
>> 	if (err)
>> 		goto out_md_fid;
>> @@ -1675,7 +1675,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
>> 
>> 	/* Some amount of caching on the client is allowed */
>> 	rc = ll_statfs_internal(sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				0);
>> 	if (rc)
>> 		return rc;
>> diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
>> index 644bea2f9d37..164fe4d6b6b8 100644
>> --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
>> +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
>> @@ -53,7 +53,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%u\n", osfs.os_bsize);
>> @@ -71,7 +71,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -96,7 +96,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -121,7 +121,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -146,7 +146,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%llu\n", osfs.os_files);
>> @@ -164,7 +164,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%llu\n", osfs.os_ffree);
>> diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
>> index 6f996acf6aa8..b4a6ee6c83f3 100644
>> --- a/drivers/staging/lustre/lustre/llite/statahead.c
>> +++ b/drivers/staging/lustre/lustre/llite/statahead.c
>> @@ -523,7 +523,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
>> 	 *    affect the performance.
>> 	 */
>> 	if (lli->lli_glimpse_time != 0 &&
>> -	    time_before(cfs_time_shift(-1), lli->lli_glimpse_time)) {
>> +	    time_before(jiffies - 1 * HZ, lli->lli_glimpse_time)) {
>> 		up_write(&lli->lli_glimpse_sem);
>> 		lli->lli_agl_index = 0;
>> 		iput(inode);
>> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
>> index e8a9b9902c37..7be931039e3c 100644
>> --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
>> +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
>> @@ -876,7 +876,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
>> 			return -EFAULT;
>> 
>> 		rc = obd_statfs(NULL, tgt->ltd_exp, &stat_buf,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				0);
>> 		if (rc)
>> 			return rc;
>> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
>> index ec70c12e5b40..355e87ecc62d 100644
>> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
>> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
>> @@ -1063,7 +1063,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
>> 
>> 		/* got statfs data */
>> 		rc = obd_statfs(NULL, lov->lov_tgts[index]->ltd_exp, &stat_buf,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				flags);
>> 		if (rc)
>> 			return rc;
>> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
>> index 3b1c8e5a3053..266fa90cb03d 100644
>> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
>> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
>> @@ -2104,7 +2104,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
>> 		}
>> 
>> 		rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				0);
>> 		if (rc != 0)
>> 			goto out;
>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> index 2ed350527398..eb6396add78d 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> @@ -407,7 +407,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%u\n", osfs.os_bsize);
>> @@ -423,7 +423,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -446,7 +446,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -469,7 +469,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -492,7 +492,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%llu\n", osfs.os_files);
>> @@ -508,7 +508,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%llu\n", osfs.os_ffree);
>> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
>> index 277576b586db..eab03766236f 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
>> @@ -269,7 +269,7 @@ static int class_attach(struct lustre_cfg *lcfg)
>> 	/* obd->obd_osfs_age must be set to a value in the distant
>> 	 * past to guarantee a fresh statfs is fetched on mount.
>> 	 */
>> -	obd->obd_osfs_age = cfs_time_shift_64(-1000);
>> +	obd->obd_osfs_age = get_jiffies_64() - 1000 * HZ;
>> 
>> 	/* XXX belongs in setup not attach  */
>> 	init_rwsem(&obd->obd_observer_link_sem);
>> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
>> index 9966fc7af789..04d801f11ace 100644
>> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
>> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
>> @@ -617,7 +617,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
>> void osc_update_next_shrink(struct client_obd *cli)
>> {
>> 	cli->cl_next_shrink_grant =
>> -		cfs_time_shift(cli->cl_grant_shrink_interval);
>> +		jiffies + cli->cl_grant_shrink_interval * HZ;
>> 	CDEBUG(D_CACHE, "next time %ld to shrink grant\n",
>> 	       cli->cl_next_shrink_grant);
>> }
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
>> index e836591c5936..7057b4447035 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
>> @@ -108,7 +108,7 @@ static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
>> 				  at_get(&imp->imp_at.iat_net_latency));
>> 		time = min(time, dtime);
>> 	}
>> -	imp->imp_next_ping = cfs_time_shift(time);
>> +	imp->imp_next_ping = jiffies + time * HZ;
>> }
>> 
>> static inline int imp_is_deactive(struct obd_import *imp)
>> @@ -120,9 +120,9 @@ static inline int imp_is_deactive(struct obd_import *imp)
>> static inline int ptlrpc_next_reconnect(struct obd_import *imp)
>> {
>> 	if (imp->imp_server_timeout)
>> -		return cfs_time_shift(obd_timeout / 2);
>> +		return jiffies + obd_timeout / 2 * HZ;
>> 	else
>> -		return cfs_time_shift(obd_timeout);
>> +		return jiffies + obd_timeout * HZ;
>> }
>> 
>> static long pinger_check_timeout(unsigned long time)
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
>> index e71046db28e5..4265e8d00ca5 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
>> @@ -922,7 +922,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
>> 	if (next <= 0) {
>> 		ptlrpc_at_timer(&svcpt->scp_at_timer);
>> 	} else {
>> -		mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
>> +		mod_timer(&svcpt->scp_at_timer, jiffies + next * HZ);
>> 		CDEBUG(D_INFO, "armed %s at %+ds\n",
>> 		       svcpt->scp_service->srv_name, next);
>> 	}
>> 
>> 
>> 

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
@ 2018-04-02 19:34       ` Dilger, Andreas
  0 siblings, 0 replies; 86+ messages in thread
From: Dilger, Andreas @ 2018-04-02 19:34 UTC (permalink / raw)
  To: James Simmons
  Cc: NeilBrown, Drokin, Oleg, Greg Kroah-Hartman,
	Linux Kernel Mailing List, Lustre Development List


> On Mar 30, 2018, at 13:02, James Simmons <jsimmons@infradead.org> wrote:
> 
> 
>> This function simply multiplies by HZ and adds jiffies.
>> This is simple enough to be opencoded, and doing so
>> makes the code easier to read.
>> 
>> Same for cfs_time_shift_64()
> 
> Reviewed-by: James Simmons <jsimmons@infradead.org>

Hmm, I thought we were trying to get rid of direct HZ usage in modules,
because of tickless systems, and move to e.g. msecs_to_jiffies() or similar?

Cheers, Andreas

> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>> .../lustre/include/linux/libcfs/libcfs_time.h      |    5 ----
>> .../lustre/include/linux/libcfs/linux/linux-time.h |    5 ----
>> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c    |   12 +++++----
>> .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |    4 ++-
>> .../staging/lustre/lnet/klnds/socklnd/socklnd.c    |    4 ++-
>> .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   12 +++++----
>> drivers/staging/lustre/lnet/lnet/net_fault.c       |   26 ++++++++++----------
>> drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
>> drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    2 +-
>> drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 +-
>> drivers/staging/lustre/lustre/llite/llite_lib.c    |    4 ++-
>> drivers/staging/lustre/lustre/llite/lproc_llite.c  |   12 +++++----
>> drivers/staging/lustre/lustre/llite/statahead.c    |    2 +-
>> drivers/staging/lustre/lustre/lmv/lmv_obd.c        |    2 +-
>> drivers/staging/lustre/lustre/lov/lov_obd.c        |    2 +-
>> drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 +-
>> .../lustre/lustre/obdclass/lprocfs_status.c        |   12 +++++----
>> .../staging/lustre/lustre/obdclass/obd_config.c    |    2 +-
>> drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +-
>> drivers/staging/lustre/lustre/ptlrpc/pinger.c      |    6 ++---
>> drivers/staging/lustre/lustre/ptlrpc/service.c     |    2 +-
>> 21 files changed, 56 insertions(+), 66 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
>> index 7b41a129f041..0ebbde4ec8e8 100644
>> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
>> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
>> @@ -50,11 +50,6 @@ static inline int cfs_time_aftereq(unsigned long t1, unsigned long t2)
>> 	return time_before_eq(t2, t1);
>> }
>> 
>> -static inline unsigned long cfs_time_shift(int seconds)
>> -{
>> -	return jiffies + seconds * HZ;
>> -}
>> -
>> /*
>>  * return valid time-out based on user supplied one. Currently we only check
>>  * that time-out is not shorted than allowed.
>> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> index b3a80531bd71..ff3aae2f1231 100644
>> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> @@ -65,11 +65,6 @@ static inline long cfs_duration_sec(long d)
>> 	return d / msecs_to_jiffies(MSEC_PER_SEC);
>> }
>> 
>> -static inline u64 cfs_time_shift_64(int seconds)
>> -{
>> -	return get_jiffies_64() + (u64)seconds * HZ;
>> -}
>> -
>> static inline int cfs_time_before_64(u64 t1, u64 t2)
>> {
>> 	return (__s64)t2 - (__s64)t1 > 0;
>> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
>> index 7df07f39b849..276bf486f64b 100644
>> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
>> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
>> @@ -1446,7 +1446,7 @@ static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps,
>> 	if (rc)
>> 		goto out_fpo;
>> 
>> -	fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
>> +	fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>> 	fpo->fpo_owner = fps;
>> 	*pp_fpo = fpo;
>> 
>> @@ -1619,7 +1619,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
>> 	spin_lock(&fps->fps_lock);
>> 	version = fps->fps_version;
>> 	list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
>> -		fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
>> +		fpo->fpo_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>> 		fpo->fpo_map_count++;
>> 
>> 		if (fpo->fpo_is_fmr) {
>> @@ -1743,7 +1743,7 @@ int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx,
>> 		fps->fps_version++;
>> 		list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
>> 	} else {
>> -		fps->fps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
>> +		fps->fps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
>> 	}
>> 	spin_unlock(&fps->fps_lock);
>> 
>> @@ -1764,7 +1764,7 @@ static void kiblnd_init_pool(struct kib_poolset *ps, struct kib_pool *pool, int
>> 
>> 	memset(pool, 0, sizeof(*pool));
>> 	INIT_LIST_HEAD(&pool->po_free_list);
>> -	pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
>> +	pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>> 	pool->po_owner    = ps;
>> 	pool->po_size     = size;
>> }
>> @@ -1899,7 +1899,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>> 			continue;
>> 
>> 		pool->po_allocated++;
>> -		pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
>> +		pool->po_deadline = jiffies + IBLND_POOL_DEADLINE * HZ;
>> 		node = pool->po_free_list.next;
>> 		list_del(node);
>> 
>> @@ -1947,7 +1947,7 @@ struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps)
>> 	if (!rc) {
>> 		list_add_tail(&pool->po_list, &ps->ps_pool_list);
>> 	} else {
>> -		ps->ps_next_retry = cfs_time_shift(IBLND_POOL_RETRY);
>> +		ps->ps_next_retry = jiffies + IBLND_POOL_RETRY * HZ;
>> 		CERROR("Can't allocate new %s pool because out of memory\n",
>> 		       ps->ps_name);
>> 	}
>> diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
>> index c1c3277f4c1f..f9761d8f2e3e 100644
>> --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
>> +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
>> @@ -3700,13 +3700,13 @@ kiblnd_failover_thread(void *arg)
>> 			LASSERT(dev->ibd_failover);
>> 			dev->ibd_failover = 0;
>> 			if (rc >= 0) { /* Device is OK or failover succeed */
>> -				dev->ibd_next_failover = cfs_time_shift(3);
>> +				dev->ibd_next_failover = jiffies + 3 * HZ;
>> 				continue;
>> 			}
>> 
>> 			/* failed to failover, retry later */
>> 			dev->ibd_next_failover =
>> -				cfs_time_shift(min(dev->ibd_failed_failover, 10));
>> +				jiffies + min(dev->ibd_failed_failover, 10) * HZ;
>> 			if (kiblnd_dev_can_failover(dev)) {
>> 				list_add_tail(&dev->ibd_fail_list,
>> 					      &kiblnd_data.kib_failed_devs);
>> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
>> index 4546618c1c12..16c1ab0b0bd9 100644
>> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
>> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
>> @@ -1287,7 +1287,7 @@ ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route,
>> 	conn->ksnc_tx_last_post = jiffies;
>> 	/* Set the deadline for the outgoing HELLO to drain */
>> 	conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued;
>> -	conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +	conn->ksnc_tx_deadline = jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 	mb();   /* order with adding to peer's conn list */
>> 
>> 	list_add(&conn->ksnc_list, &peer->ksnp_conns);
>> @@ -1852,7 +1852,7 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
>> 			if (bufnob < conn->ksnc_tx_bufnob) {
>> 				/* something got ACKed */
>> 				conn->ksnc_tx_deadline =
>> -					cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +					jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 				peer->ksnp_last_alive = now;
>> 				conn->ksnc_tx_bufnob = bufnob;
>> 			}
>> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
>> index 5b34c7c030ad..1ace54c9b133 100644
>> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
>> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
>> @@ -221,7 +221,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
>> 			 * something got ACKed
>> 			 */
>> 			conn->ksnc_tx_deadline =
>> -				cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +				jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 			conn->ksnc_peer->ksnp_last_alive = jiffies;
>> 			conn->ksnc_tx_bufnob = bufnob;
>> 			mb();
>> @@ -269,7 +269,7 @@ ksocknal_recv_iter(struct ksock_conn *conn)
>> 
>> 	conn->ksnc_peer->ksnp_last_alive = jiffies;
>> 	conn->ksnc_rx_deadline =
>> -		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 	mb();		       /* order with setting rx_started */
>> 	conn->ksnc_rx_started = 1;
>> 
>> @@ -405,7 +405,7 @@ ksocknal_check_zc_req(struct ksock_tx *tx)
>> 
>> 	/* ZC_REQ is going to be pinned to the peer */
>> 	tx->tx_deadline =
>> -		cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +		jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 
>> 	LASSERT(!tx->tx_msg.ksm_zc_cookies[0]);
>> 
>> @@ -677,7 +677,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
>> 	if (list_empty(&conn->ksnc_tx_queue) && !bufnob) {
>> 		/* First packet starts the timeout */
>> 		conn->ksnc_tx_deadline =
>> -			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 		if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
>> 			conn->ksnc_peer->ksnp_last_alive = jiffies;
>> 		conn->ksnc_tx_bufnob = 0;
>> @@ -858,7 +858,7 @@ ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
>> 	    ksocknal_find_connecting_route_locked(peer)) {
>> 		/* the message is going to be pinned to the peer */
>> 		tx->tx_deadline =
>> -			cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
>> +			jiffies + *ksocknal_tunables.ksnd_timeout * HZ;
>> 
>> 		/* Queue the message until a connection is established */
>> 		list_add_tail(&tx->tx_list, &peer->ksnp_tx_queue);
>> @@ -2308,7 +2308,7 @@ ksocknal_send_keepalive_locked(struct ksock_peer *peer)
>> 	 * retry 10 secs later, so we wouldn't put pressure
>> 	 * on this peer if we failed to send keepalive this time
>> 	 */
>> -	peer->ksnp_send_keepalive = cfs_time_shift(10);
>> +	peer->ksnp_send_keepalive = jiffies + 10 * HZ;
>> 
>> 	conn = ksocknal_find_conn_locked(peer, NULL, 1);
>> 	if (conn) {
>> diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c
>> index 3928e9a74d6f..05d7b754815a 100644
>> --- a/drivers/staging/lustre/lnet/lnet/net_fault.c
>> +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
>> @@ -169,9 +169,9 @@ lnet_drop_rule_add(struct lnet_fault_attr *attr)
>> 
>> 	rule->dr_attr = *attr;
>> 	if (attr->u.drop.da_interval) {
>> -		rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
>> -		rule->dr_drop_time = cfs_time_shift(
>> -			prandom_u32_max(attr->u.drop.da_interval));
>> +		rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
>> +		rule->dr_drop_time = jiffies +
>> +			prandom_u32_max(attr->u.drop.da_interval) * HZ;
>> 	} else {
>> 		rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
>> 	}
>> @@ -279,9 +279,9 @@ lnet_drop_rule_reset(void)
>> 		if (attr->u.drop.da_rate) {
>> 			rule->dr_drop_at = prandom_u32_max(attr->u.drop.da_rate);
>> 		} else {
>> -			rule->dr_drop_time = cfs_time_shift(
>> -				prandom_u32_max(attr->u.drop.da_interval));
>> -			rule->dr_time_base = cfs_time_shift(attr->u.drop.da_interval);
>> +			rule->dr_drop_time = jiffies +
>> +				prandom_u32_max(attr->u.drop.da_interval) * HZ;
>> +			rule->dr_time_base = jiffies + attr->u.drop.da_interval * HZ;
>> 		}
>> 		spin_unlock(&rule->dr_lock);
>> 	}
>> @@ -513,7 +513,7 @@ delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
>> 
>> 	list_add_tail(&msg->msg_list, &rule->dl_msg_list);
>> 	msg->msg_delay_send = round_timeout(
>> -			cfs_time_shift(attr->u.delay.la_latency));
>> +			jiffies + attr->u.delay.la_latency * HZ);
>> 	if (rule->dl_msg_send == -1) {
>> 		rule->dl_msg_send = msg->msg_delay_send;
>> 		mod_timer(&rule->dl_timer, rule->dl_msg_send);
>> @@ -767,9 +767,9 @@ lnet_delay_rule_add(struct lnet_fault_attr *attr)
>> 
>> 	rule->dl_attr = *attr;
>> 	if (attr->u.delay.la_interval) {
>> -		rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
>> -		rule->dl_delay_time = cfs_time_shift(
>> -			prandom_u32_max(attr->u.delay.la_interval));
>> +		rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
>> +		rule->dl_delay_time = jiffies + 
>> +			prandom_u32_max(attr->u.delay.la_interval) * HZ;
>> 	} else {
>> 		rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
>> 	}
>> @@ -920,9 +920,9 @@ lnet_delay_rule_reset(void)
>> 			rule->dl_delay_at = prandom_u32_max(attr->u.delay.la_rate);
>> 		} else {
>> 			rule->dl_delay_time =
>> -				cfs_time_shift(prandom_u32_max(
>> -						       attr->u.delay.la_interval));
>> -			rule->dl_time_base = cfs_time_shift(attr->u.delay.la_interval);
>> +				jiffies + prandom_u32_max(
>> +					attr->u.delay.la_interval) * HZ;
>> +			rule->dl_time_base = jiffies + attr->u.delay.la_interval * HZ;
>> 		}
>> 		spin_unlock(&rule->dl_lock);
>> 	}
>> diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
>> index 4595a7ad4336..c72d4f4454ec 100644
>> --- a/drivers/staging/lustre/lnet/lnet/router.c
>> +++ b/drivers/staging/lustre/lnet/lnet/router.c
>> @@ -1026,7 +1026,7 @@ lnet_ping_router_locked(struct lnet_peer *rtr)
>> 
>> 		if (!rtr->lp_ping_deadline) {
>> 			rtr->lp_ping_deadline =
>> -				cfs_time_shift(router_ping_timeout);
>> +				jiffies + router_ping_timeout * HZ;
>> 		}
>> 
>> 		lnet_net_unlock(rtr->lp_cpt);
>> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
>> index 6eb42f16040d..647e85b16c02 100644
>> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
>> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
>> @@ -118,7 +118,7 @@ static void ldlm_expired_completion_wait(struct ldlm_lock *lock, __u32 conn_cnt)
>> 				 lock->l_last_activity));
>> 		if (cfs_time_after(jiffies, next_dump)) {
>> 			last_dump = next_dump;
>> -			next_dump = cfs_time_shift(300);
>> +			next_dump = jiffies + 300 * HZ;
>> 			ldlm_namespace_dump(D_DLMTRACE,
>> 					    ldlm_lock_to_ns(lock));
>> 			if (last_dump == 0)
>> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
>> index ccd0c082e39b..6c615b6e9bdc 100644
>> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
>> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
>> @@ -1323,7 +1323,7 @@ void ldlm_namespace_dump(int level, struct ldlm_namespace *ns)
>> 				 ldlm_res_hash_dump,
>> 				 (void *)(unsigned long)level, 0);
>> 	spin_lock(&ns->ns_lock);
>> -	ns->ns_next_dump = cfs_time_shift(10);
>> +	ns->ns_next_dump = jiffies + 10 * HZ;
>> 	spin_unlock(&ns->ns_lock);
>> }
>> 
>> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
>> index e7500c53fafc..60dbe888e336 100644
>> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
>> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
>> @@ -257,7 +257,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
>> 	 * available
>> 	 */
>> 	err = obd_statfs(NULL, sbi->ll_md_exp, osfs,
>> -			 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			 get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			 OBD_STATFS_FOR_MDT0);
>> 	if (err)
>> 		goto out_md_fid;
>> @@ -1675,7 +1675,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs)
>> 
>> 	/* Some amount of caching on the client is allowed */
>> 	rc = ll_statfs_internal(sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				0);
>> 	if (rc)
>> 		return rc;
>> diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
>> index 644bea2f9d37..164fe4d6b6b8 100644
>> --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
>> +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
>> @@ -53,7 +53,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%u\n", osfs.os_bsize);
>> @@ -71,7 +71,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -96,7 +96,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -121,7 +121,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -146,7 +146,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%llu\n", osfs.os_files);
>> @@ -164,7 +164,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
>> 	int rc;
>> 
>> 	rc = ll_statfs_internal(sbi->ll_sb, &osfs,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%llu\n", osfs.os_ffree);
>> diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
>> index 6f996acf6aa8..b4a6ee6c83f3 100644
>> --- a/drivers/staging/lustre/lustre/llite/statahead.c
>> +++ b/drivers/staging/lustre/lustre/llite/statahead.c
>> @@ -523,7 +523,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
>> 	 *    affect the performance.
>> 	 */
>> 	if (lli->lli_glimpse_time != 0 &&
>> -	    time_before(cfs_time_shift(-1), lli->lli_glimpse_time)) {
>> +	    time_before(jiffies - 1 * HZ, lli->lli_glimpse_time)) {
>> 		up_write(&lli->lli_glimpse_sem);
>> 		lli->lli_agl_index = 0;
>> 		iput(inode);
>> diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
>> index e8a9b9902c37..7be931039e3c 100644
>> --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
>> +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
>> @@ -876,7 +876,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
>> 			return -EFAULT;
>> 
>> 		rc = obd_statfs(NULL, tgt->ltd_exp, &stat_buf,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				0);
>> 		if (rc)
>> 			return rc;
>> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
>> index ec70c12e5b40..355e87ecc62d 100644
>> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
>> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
>> @@ -1063,7 +1063,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
>> 
>> 		/* got statfs data */
>> 		rc = obd_statfs(NULL, lov->lov_tgts[index]->ltd_exp, &stat_buf,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				flags);
>> 		if (rc)
>> 			return rc;
>> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
>> index 3b1c8e5a3053..266fa90cb03d 100644
>> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
>> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
>> @@ -2104,7 +2104,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
>> 		}
>> 
>> 		rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf,
>> -				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +				get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 				0);
>> 		if (rc != 0)
>> 			goto out;
>> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> index 2ed350527398..eb6396add78d 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
>> @@ -407,7 +407,7 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%u\n", osfs.os_bsize);
>> @@ -423,7 +423,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -446,7 +446,7 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -469,7 +469,7 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc) {
>> 		__u32 blk_size = osfs.os_bsize >> 10;
>> @@ -492,7 +492,7 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%llu\n", osfs.os_files);
>> @@ -508,7 +508,7 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
>> 					      obd_kobj);
>> 	struct obd_statfs  osfs;
>> 	int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
>> -			    cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
>> +			    get_jiffies_64() - OBD_STATFS_CACHE_SECONDS * HZ,
>> 			    OBD_STATFS_NODELAY);
>> 	if (!rc)
>> 		return sprintf(buf, "%llu\n", osfs.os_ffree);
>> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
>> index 277576b586db..eab03766236f 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
>> @@ -269,7 +269,7 @@ static int class_attach(struct lustre_cfg *lcfg)
>> 	/* obd->obd_osfs_age must be set to a value in the distant
>> 	 * past to guarantee a fresh statfs is fetched on mount.
>> 	 */
>> -	obd->obd_osfs_age = cfs_time_shift_64(-1000);
>> +	obd->obd_osfs_age = get_jiffies_64() - 1000 * HZ;
>> 
>> 	/* XXX belongs in setup not attach  */
>> 	init_rwsem(&obd->obd_observer_link_sem);
>> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
>> index 9966fc7af789..04d801f11ace 100644
>> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
>> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
>> @@ -617,7 +617,7 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
>> void osc_update_next_shrink(struct client_obd *cli)
>> {
>> 	cli->cl_next_shrink_grant =
>> -		cfs_time_shift(cli->cl_grant_shrink_interval);
>> +		jiffies + cli->cl_grant_shrink_interval * HZ;
>> 	CDEBUG(D_CACHE, "next time %ld to shrink grant\n",
>> 	       cli->cl_next_shrink_grant);
>> }
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
>> index e836591c5936..7057b4447035 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
>> @@ -108,7 +108,7 @@ static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
>> 				  at_get(&imp->imp_at.iat_net_latency));
>> 		time = min(time, dtime);
>> 	}
>> -	imp->imp_next_ping = cfs_time_shift(time);
>> +	imp->imp_next_ping = jiffies + time * HZ;
>> }
>> 
>> static inline int imp_is_deactive(struct obd_import *imp)
>> @@ -120,9 +120,9 @@ static inline int imp_is_deactive(struct obd_import *imp)
>> static inline int ptlrpc_next_reconnect(struct obd_import *imp)
>> {
>> 	if (imp->imp_server_timeout)
>> -		return cfs_time_shift(obd_timeout / 2);
>> +		return jiffies + obd_timeout / 2 * HZ;
>> 	else
>> -		return cfs_time_shift(obd_timeout);
>> +		return jiffies + obd_timeout * HZ;
>> }
>> 
>> static long pinger_check_timeout(unsigned long time)
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
>> index e71046db28e5..4265e8d00ca5 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
>> @@ -922,7 +922,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt)
>> 	if (next <= 0) {
>> 		ptlrpc_at_timer(&svcpt->scp_at_timer);
>> 	} else {
>> -		mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next));
>> +		mod_timer(&svcpt->scp_at_timer, jiffies + next * HZ);
>> 		CDEBUG(D_INFO, "armed %s at %+ds\n",
>> 		       svcpt->scp_service->srv_name, next);
>> 	}
>> 
>> 
>> 

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-04-02 19:38     ` Dilger, Andreas
  -1 siblings, 0 replies; 86+ messages in thread
From: Dilger, Andreas @ 2018-04-02 19:38 UTC (permalink / raw)
  To: NeilBrown
  Cc: Drokin, Oleg, Greg Kroah-Hartman, James Simmons,
	Linux Kernel Mailing List, Lustre Development List

On Mar 28, 2018, at 22:26, NeilBrown <neilb@suse.com> wrote:
> 
> This wrapper is only used once, so open-code it as max().
> 
> This allows us to remove the libcfs_time.h include file.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
> .../staging/lustre/include/linux/libcfs/libcfs.h   |    1 
> .../lustre/include/linux/libcfs/libcfs_time.h      |   50 --------------------
> .../lustre/include/linux/libcfs/linux/linux-time.h |    2 -
> drivers/staging/lustre/lustre/ptlrpc/import.c      |    4 +-
> 4 files changed, 3 insertions(+), 54 deletions(-)
> delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> index 3b751c436b3d..3d3fa52858e5 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> @@ -43,7 +43,6 @@
> #include <linux/libcfs/libcfs_private.h>
> #include <linux/libcfs/libcfs_cpu.h>
> #include <linux/libcfs/libcfs_prim.h>
> -#include <linux/libcfs/libcfs_time.h>
> #include <linux/libcfs/libcfs_string.h>
> #include <linux/libcfs/libcfs_hash.h>
> #include <linux/libcfs/libcfs_fail.h>
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> deleted file mode 100644
> index 172a8872e3f3..000000000000
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ /dev/null
> @@ -1,50 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * GPL HEADER START
> - *
> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 only,
> - * as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * General Public License version 2 for more details (a copy is included
> - * in the LICENSE file that accompanied this code).
> - *
> - * You should have received a copy of the GNU General Public License
> - * version 2 along with this program; If not, see
> - * http://www.gnu.org/licenses/gpl-2.0.html
> - *
> - * GPL HEADER END
> - */
> -/*
> - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
> - * Use is subject to license terms.
> - */
> -/*
> - * This file is part of Lustre, http://www.lustre.org/
> - * Lustre is a trademark of Sun Microsystems, Inc.
> - *
> - * libcfs/include/libcfs/libcfs_time.h
> - *
> - * Time functions.
> - *
> - */
> -
> -#ifndef __LIBCFS_TIME_H__
> -#define __LIBCFS_TIME_H__
> -/*
> - * return valid time-out based on user supplied one. Currently we only check
> - * that time-out is not shorted than allowed.
> - */
> -static inline long cfs_timeout_cap(long timeout)
> -{
> -	if (timeout < CFS_TICK)
> -		timeout = CFS_TICK;
> -	return timeout;
> -}
> -
> -#endif
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index ff3aae2f1231..ecb2126a9e6f 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
> /*
>  * One jiffy
>  */
> -#define CFS_TICK		(1)
> +#define CFS_TICK		(1UL)

It seems like CFS_TICK is mostly useless as well and could just be dropped?

> #define CFS_DURATION_T	  "%ld"
> 
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index 4a9d1f189d01..dd4fd54128dd 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
> 	}
> 
> 	if (ptlrpc_import_in_recovery(imp)) {
> -		long timeout;
> +		unsigned long timeout;
> 
> 		if (AT_OFF) {
> 			if (imp->imp_server_timeout)
> @@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
> 
> 		if (wait_event_idle_timeout(imp->imp_recovery_waitq,
> 					    !ptlrpc_import_in_recovery(imp),
> -					    cfs_timeout_cap(timeout)) == 0)
> +					    max(timeout, CFS_TICK)) == 0)
> 			l_wait_event_abortable(
> 				imp->imp_recovery_waitq,
> 				!ptlrpc_import_in_recovery(imp));
> 
> 

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()
@ 2018-04-02 19:38     ` Dilger, Andreas
  0 siblings, 0 replies; 86+ messages in thread
From: Dilger, Andreas @ 2018-04-02 19:38 UTC (permalink / raw)
  To: NeilBrown
  Cc: Drokin, Oleg, Greg Kroah-Hartman, James Simmons,
	Linux Kernel Mailing List, Lustre Development List

On Mar 28, 2018, at 22:26, NeilBrown <neilb@suse.com> wrote:
> 
> This wrapper is only used once, so open-code it as max().
> 
> This allows us to remove the libcfs_time.h include file.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
> .../staging/lustre/include/linux/libcfs/libcfs.h   |    1 
> .../lustre/include/linux/libcfs/libcfs_time.h      |   50 --------------------
> .../lustre/include/linux/libcfs/linux/linux-time.h |    2 -
> drivers/staging/lustre/lustre/ptlrpc/import.c      |    4 +-
> 4 files changed, 3 insertions(+), 54 deletions(-)
> delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> index 3b751c436b3d..3d3fa52858e5 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
> @@ -43,7 +43,6 @@
> #include <linux/libcfs/libcfs_private.h>
> #include <linux/libcfs/libcfs_cpu.h>
> #include <linux/libcfs/libcfs_prim.h>
> -#include <linux/libcfs/libcfs_time.h>
> #include <linux/libcfs/libcfs_string.h>
> #include <linux/libcfs/libcfs_hash.h>
> #include <linux/libcfs/libcfs_fail.h>
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> deleted file mode 100644
> index 172a8872e3f3..000000000000
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h
> +++ /dev/null
> @@ -1,50 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * GPL HEADER START
> - *
> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 only,
> - * as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * General Public License version 2 for more details (a copy is included
> - * in the LICENSE file that accompanied this code).
> - *
> - * You should have received a copy of the GNU General Public License
> - * version 2 along with this program; If not, see
> - * http://www.gnu.org/licenses/gpl-2.0.html
> - *
> - * GPL HEADER END
> - */
> -/*
> - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
> - * Use is subject to license terms.
> - */
> -/*
> - * This file is part of Lustre, http://www.lustre.org/
> - * Lustre is a trademark of Sun Microsystems, Inc.
> - *
> - * libcfs/include/libcfs/libcfs_time.h
> - *
> - * Time functions.
> - *
> - */
> -
> -#ifndef __LIBCFS_TIME_H__
> -#define __LIBCFS_TIME_H__
> -/*
> - * return valid time-out based on user supplied one. Currently we only check
> - * that time-out is not shorted than allowed.
> - */
> -static inline long cfs_timeout_cap(long timeout)
> -{
> -	if (timeout < CFS_TICK)
> -		timeout = CFS_TICK;
> -	return timeout;
> -}
> -
> -#endif
> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> index ff3aae2f1231..ecb2126a9e6f 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
> @@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
> /*
>  * One jiffy
>  */
> -#define CFS_TICK		(1)
> +#define CFS_TICK		(1UL)

It seems like CFS_TICK is mostly useless as well and could just be dropped?

> #define CFS_DURATION_T	  "%ld"
> 
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index 4a9d1f189d01..dd4fd54128dd 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
> 	}
> 
> 	if (ptlrpc_import_in_recovery(imp)) {
> -		long timeout;
> +		unsigned long timeout;
> 
> 		if (AT_OFF) {
> 			if (imp->imp_server_timeout)
> @@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
> 
> 		if (wait_event_idle_timeout(imp->imp_recovery_waitq,
> 					    !ptlrpc_import_in_recovery(imp),
> -					    cfs_timeout_cap(timeout)) == 0)
> +					    max(timeout, CFS_TICK)) == 0)
> 			l_wait_event_abortable(
> 				imp->imp_recovery_waitq,
> 				!ptlrpc_import_in_recovery(imp));
> 
> 

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
  2018-04-02 19:34       ` [lustre-devel] " Dilger, Andreas
@ 2018-04-02 22:26         ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-04-02 22:26 UTC (permalink / raw)
  To: Dilger, Andreas, James Simmons
  Cc: Drokin, Oleg, Greg Kroah-Hartman, Linux Kernel Mailing List,
	Lustre Development List

[-- Attachment #1: Type: text/plain, Size: 1435 bytes --]

On Mon, Apr 02 2018, Dilger, Andreas wrote:

>> On Mar 30, 2018, at 13:02, James Simmons <jsimmons@infradead.org> wrote:
>> 
>> 
>>> This function simply multiplies by HZ and adds jiffies.
>>> This is simple enough to be opencoded, and doing so
>>> makes the code easier to read.
>>> 
>>> Same for cfs_time_shift_64()
>> 
>> Reviewed-by: James Simmons <jsimmons@infradead.org>
>
> Hmm, I thought we were trying to get rid of direct HZ usage in modules,
> because of tickless systems, and move to e.g. msecs_to_jiffies() or similar?

Are we?  I hadn't heard but I could easily have missed it.
Documentation/scheduler/completion.txt does say

    Timeouts are preferably calculated with
    msecs_to_jiffies() or usecs_to_jiffies().

but is isn't clear what they are preferred to.  Do you remember where
you heard? or have a reference?

$ git grep ' \* *HZ'  |wc
   2244   15679  170016
$ git grep msecs_to_jiffies | wc
   3301   13151  276725

so msecs_to_jiffies is slightly more popular than "* HZ" (even if you add
in "HZ *").  But that could just be a preference for using milliseconds
over using seconds.

$ git grep msecs_to_jiffies   | grep -c '[0-9]000'
587

so there are only 587 places that msecs_to_jiffies is clearly used in
place of multiplying by HZ.

If we were to pursue this, I would want to add secs_to_jiffies() to
include/linux/jiffies.h and use that.

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
@ 2018-04-02 22:26         ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-04-02 22:26 UTC (permalink / raw)
  To: Dilger, Andreas, James Simmons
  Cc: Drokin, Oleg, Greg Kroah-Hartman, Linux Kernel Mailing List,
	Lustre Development List

On Mon, Apr 02 2018, Dilger, Andreas wrote:

>> On Mar 30, 2018, at 13:02, James Simmons <jsimmons@infradead.org> wrote:
>> 
>> 
>>> This function simply multiplies by HZ and adds jiffies.
>>> This is simple enough to be opencoded, and doing so
>>> makes the code easier to read.
>>> 
>>> Same for cfs_time_shift_64()
>> 
>> Reviewed-by: James Simmons <jsimmons@infradead.org>
>
> Hmm, I thought we were trying to get rid of direct HZ usage in modules,
> because of tickless systems, and move to e.g. msecs_to_jiffies() or similar?

Are we?  I hadn't heard but I could easily have missed it.
Documentation/scheduler/completion.txt does say

    Timeouts are preferably calculated with
    msecs_to_jiffies() or usecs_to_jiffies().

but is isn't clear what they are preferred to.  Do you remember where
you heard? or have a reference?

$ git grep ' \* *HZ'  |wc
   2244   15679  170016
$ git grep msecs_to_jiffies | wc
   3301   13151  276725

so msecs_to_jiffies is slightly more popular than "* HZ" (even if you add
in "HZ *").  But that could just be a preference for using milliseconds
over using seconds.

$ git grep msecs_to_jiffies   | grep -c '[0-9]000'
587

so there are only 587 places that msecs_to_jiffies is clearly used in
place of multiplying by HZ.

If we were to pursue this, I would want to add secs_to_jiffies() to
include/linux/jiffies.h and use that.

Thanks,
NeilBrown
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180403/ea62fac9/attachment.sig>

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()
  2018-04-02 19:38     ` [lustre-devel] " Dilger, Andreas
@ 2018-04-02 22:34       ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-04-02 22:34 UTC (permalink / raw)
  To: Dilger, Andreas
  Cc: Drokin, Oleg, Greg Kroah-Hartman, James Simmons,
	Linux Kernel Mailing List, Lustre Development List

[-- Attachment #1: Type: text/plain, Size: 2252 bytes --]

On Mon, Apr 02 2018, Dilger, Andreas wrote:

> On Mar 28, 2018, at 22:26, NeilBrown <neilb@suse.com> wrote:

>> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> index ff3aae2f1231..ecb2126a9e6f 100644
>> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> @@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
>> /*
>>  * One jiffy
>>  */
>> -#define CFS_TICK		(1)
>> +#define CFS_TICK		(1UL)
>
> It seems like CFS_TICK is mostly useless as well and could just be dropped?

Possibly, but I don't know what its purpose is so I didn't want to just
drop it in the middle of a patch that is performing an idempotent
transformation.

Do you know why the one place that uses CFS_TICK wants to protect about
a timeout of zero?  Maybe because the old l_wait_event() treated a
timeout of zero as meaning no timeout?
In that case this really is irrelevant now and that
wait_event_idle_timeout() should just use "timeout" directly.

Thanks,
NeilBrown


>
>> #define CFS_DURATION_T	  "%ld"
>> 
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
>> index 4a9d1f189d01..dd4fd54128dd 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
>> @@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
>> 	}
>> 
>> 	if (ptlrpc_import_in_recovery(imp)) {
>> -		long timeout;
>> +		unsigned long timeout;
>> 
>> 		if (AT_OFF) {
>> 			if (imp->imp_server_timeout)
>> @@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
>> 
>> 		if (wait_event_idle_timeout(imp->imp_recovery_waitq,
>> 					    !ptlrpc_import_in_recovery(imp),
>> -					    cfs_timeout_cap(timeout)) == 0)
>> +					    max(timeout, CFS_TICK)) == 0)
>> 			l_wait_event_abortable(
>> 				imp->imp_recovery_waitq,
>> 				!ptlrpc_import_in_recovery(imp));
>> 
>> 
>
> Cheers, Andreas
> --
> Andreas Dilger
> Lustre Principal Architect
> Intel Corporation

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap()
@ 2018-04-02 22:34       ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-04-02 22:34 UTC (permalink / raw)
  To: Dilger, Andreas
  Cc: Drokin, Oleg, Greg Kroah-Hartman, James Simmons,
	Linux Kernel Mailing List, Lustre Development List

On Mon, Apr 02 2018, Dilger, Andreas wrote:

> On Mar 28, 2018, at 22:26, NeilBrown <neilb@suse.com> wrote:

>> diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> index ff3aae2f1231..ecb2126a9e6f 100644
>> --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h
>> @@ -78,7 +78,7 @@ static inline int cfs_time_beforeq_64(u64 t1, u64 t2)
>> /*
>>  * One jiffy
>>  */
>> -#define CFS_TICK		(1)
>> +#define CFS_TICK		(1UL)
>
> It seems like CFS_TICK is mostly useless as well and could just be dropped?

Possibly, but I don't know what its purpose is so I didn't want to just
drop it in the middle of a patch that is performing an idempotent
transformation.

Do you know why the one place that uses CFS_TICK wants to protect about
a timeout of zero?  Maybe because the old l_wait_event() treated a
timeout of zero as meaning no timeout?
In that case this really is irrelevant now and that
wait_event_idle_timeout() should just use "timeout" directly.

Thanks,
NeilBrown


>
>> #define CFS_DURATION_T	  "%ld"
>> 
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
>> index 4a9d1f189d01..dd4fd54128dd 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
>> @@ -1486,7 +1486,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
>> 	}
>> 
>> 	if (ptlrpc_import_in_recovery(imp)) {
>> -		long timeout;
>> +		unsigned long timeout;
>> 
>> 		if (AT_OFF) {
>> 			if (imp->imp_server_timeout)
>> @@ -1501,7 +1501,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
>> 
>> 		if (wait_event_idle_timeout(imp->imp_recovery_waitq,
>> 					    !ptlrpc_import_in_recovery(imp),
>> -					    cfs_timeout_cap(timeout)) == 0)
>> +					    max(timeout, CFS_TICK)) == 0)
>> 			l_wait_event_abortable(
>> 				imp->imp_recovery_waitq,
>> 				!ptlrpc_import_in_recovery(imp));
>> 
>> 
>
> Cheers, Andreas
> --
> Andreas Dilger
> Lustre Principal Architect
> Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180403/d8e8f6a8/attachment.sig>

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [lustre-devel] [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
  2018-04-02 22:26         ` [lustre-devel] " NeilBrown
@ 2018-04-04  8:10           ` Dilger, Andreas
  -1 siblings, 0 replies; 86+ messages in thread
From: Dilger, Andreas @ 2018-04-04  8:10 UTC (permalink / raw)
  To: NeilBrown
  Cc: James Simmons, Drokin, Oleg, Greg Kroah-Hartman,
	Linux Kernel Mailing List, Lustre Development List

On Apr 2, 2018, at 16:26, NeilBrown <neilb@suse.com> wrote:
> On Mon, Apr 02 2018, Dilger, Andreas wrote:
>> On Mar 30, 2018, at 13:02, James Simmons <jsimmons@infradead.org> wrote:
>>>> This function simply multiplies by HZ and adds jiffies.
>>>> This is simple enough to be opencoded, and doing so
>>>> makes the code easier to read.
>>>> 
>>>> Same for cfs_time_shift_64()
>>> 
>>> Reviewed-by: James Simmons <jsimmons@infradead.org>
>> 
>> Hmm, I thought we were trying to get rid of direct HZ usage in modules,
>> because of tickless systems, and move to e.g. msecs_to_jiffies() or similar?
> 
> Are we?  I hadn't heard but I could easily have missed it.
> Documentation/scheduler/completion.txt does say
> 
>    Timeouts are preferably calculated with
>    msecs_to_jiffies() or usecs_to_jiffies().
> 
> but is isn't clear what they are preferred to.  Do you remember where
> you heard? or have a reference?

I thought the goal was to avoid hard-coding the HZ value so that kernels
could have variable clock rates in the future.

Cheers, Andreas

> $ git grep ' \* *HZ'  |wc
>   2244   15679  170016
> $ git grep msecs_to_jiffies | wc
>   3301   13151  276725
> 
> so msecs_to_jiffies is slightly more popular than "* HZ" (even if you add
> in "HZ *").  But that could just be a preference for using milliseconds
> over using seconds.
> 
> $ git grep msecs_to_jiffies   | grep -c '[0-9]000'
> 587
> 
> so there are only 587 places that msecs_to_jiffies is clearly used in
> place of multiplying by HZ.
> 
> If we were to pursue this, I would want to add secs_to_jiffies() to
> include/linux/jiffies.h and use that.
> 
> Thanks,
> NeilBrown
> _______________________________________________
> lustre-devel mailing list
> lustre-devel@lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
@ 2018-04-04  8:10           ` Dilger, Andreas
  0 siblings, 0 replies; 86+ messages in thread
From: Dilger, Andreas @ 2018-04-04  8:10 UTC (permalink / raw)
  To: NeilBrown
  Cc: James Simmons, Drokin, Oleg, Greg Kroah-Hartman,
	Linux Kernel Mailing List, Lustre Development List

On Apr 2, 2018, at 16:26, NeilBrown <neilb@suse.com> wrote:
> On Mon, Apr 02 2018, Dilger, Andreas wrote:
>> On Mar 30, 2018, at 13:02, James Simmons <jsimmons@infradead.org> wrote:
>>>> This function simply multiplies by HZ and adds jiffies.
>>>> This is simple enough to be opencoded, and doing so
>>>> makes the code easier to read.
>>>> 
>>>> Same for cfs_time_shift_64()
>>> 
>>> Reviewed-by: James Simmons <jsimmons@infradead.org>
>> 
>> Hmm, I thought we were trying to get rid of direct HZ usage in modules,
>> because of tickless systems, and move to e.g. msecs_to_jiffies() or similar?
> 
> Are we?  I hadn't heard but I could easily have missed it.
> Documentation/scheduler/completion.txt does say
> 
>    Timeouts are preferably calculated with
>    msecs_to_jiffies() or usecs_to_jiffies().
> 
> but is isn't clear what they are preferred to.  Do you remember where
> you heard? or have a reference?

I thought the goal was to avoid hard-coding the HZ value so that kernels
could have variable clock rates in the future.

Cheers, Andreas

> $ git grep ' \* *HZ'  |wc
>   2244   15679  170016
> $ git grep msecs_to_jiffies | wc
>   3301   13151  276725
> 
> so msecs_to_jiffies is slightly more popular than "* HZ" (even if you add
> in "HZ *").  But that could just be a preference for using milliseconds
> over using seconds.
> 
> $ git grep msecs_to_jiffies   | grep -c '[0-9]000'
> 587
> 
> so there are only 587 places that msecs_to_jiffies is clearly used in
> place of multiplying by HZ.
> 
> If we were to pursue this, I would want to add secs_to_jiffies() to
> include/linux/jiffies.h and use that.
> 
> Thanks,
> NeilBrown
> _______________________________________________
> lustre-devel mailing list
> lustre-devel at lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [lustre-devel] [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
  2018-04-04  8:10           ` Dilger, Andreas
@ 2018-04-04 22:00             ` NeilBrown
  -1 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-04-04 22:00 UTC (permalink / raw)
  To: Dilger, Andreas
  Cc: James Simmons, Drokin, Oleg, Greg Kroah-Hartman,
	Linux Kernel Mailing List, Lustre Development List

[-- Attachment #1: Type: text/plain, Size: 2547 bytes --]

On Wed, Apr 04 2018, Dilger, Andreas wrote:

> On Apr 2, 2018, at 16:26, NeilBrown <neilb@suse.com> wrote:
>> On Mon, Apr 02 2018, Dilger, Andreas wrote:
>>> On Mar 30, 2018, at 13:02, James Simmons <jsimmons@infradead.org> wrote:
>>>>> This function simply multiplies by HZ and adds jiffies.
>>>>> This is simple enough to be opencoded, and doing so
>>>>> makes the code easier to read.
>>>>> 
>>>>> Same for cfs_time_shift_64()
>>>> 
>>>> Reviewed-by: James Simmons <jsimmons@infradead.org>
>>> 
>>> Hmm, I thought we were trying to get rid of direct HZ usage in modules,
>>> because of tickless systems, and move to e.g. msecs_to_jiffies() or similar?
>> 
>> Are we?  I hadn't heard but I could easily have missed it.
>> Documentation/scheduler/completion.txt does say
>> 
>>    Timeouts are preferably calculated with
>>    msecs_to_jiffies() or usecs_to_jiffies().
>> 
>> but is isn't clear what they are preferred to.  Do you remember where
>> you heard? or have a reference?
>
> I thought the goal was to avoid hard-coding the HZ value so that kernels
> could have variable clock rates in the future.

It is hard to imagine it ever being possible to change, at runtime, the
length of time represented by one jiffie.
Durations, measured in jiffies, are stored it lots of different places,
and they would all need to be changed to msecs - very error prone work.
I think it would be much more likely to set HZ to some large value, and
have the clock tick at varying multiples of that.  The NOHZ work already
does something a bit like that I think.

Thanks,
NeilBrown

>
> Cheers, Andreas
>
>> $ git grep ' \* *HZ'  |wc
>>   2244   15679  170016
>> $ git grep msecs_to_jiffies | wc
>>   3301   13151  276725
>> 
>> so msecs_to_jiffies is slightly more popular than "* HZ" (even if you add
>> in "HZ *").  But that could just be a preference for using milliseconds
>> over using seconds.
>> 
>> $ git grep msecs_to_jiffies   | grep -c '[0-9]000'
>> 587
>> 
>> so there are only 587 places that msecs_to_jiffies is clearly used in
>> place of multiplying by HZ.
>> 
>> If we were to pursue this, I would want to add secs_to_jiffies() to
>> include/linux/jiffies.h and use that.
>> 
>> Thanks,
>> NeilBrown
>> _______________________________________________
>> lustre-devel mailing list
>> lustre-devel@lists.lustre.org
>> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
>
> Cheers, Andreas
> --
> Andreas Dilger
> Lustre Principal Architect
> Intel Corporation

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift().
@ 2018-04-04 22:00             ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-04-04 22:00 UTC (permalink / raw)
  To: Dilger, Andreas
  Cc: James Simmons, Drokin, Oleg, Greg Kroah-Hartman,
	Linux Kernel Mailing List, Lustre Development List

On Wed, Apr 04 2018, Dilger, Andreas wrote:

> On Apr 2, 2018, at 16:26, NeilBrown <neilb@suse.com> wrote:
>> On Mon, Apr 02 2018, Dilger, Andreas wrote:
>>> On Mar 30, 2018, at 13:02, James Simmons <jsimmons@infradead.org> wrote:
>>>>> This function simply multiplies by HZ and adds jiffies.
>>>>> This is simple enough to be opencoded, and doing so
>>>>> makes the code easier to read.
>>>>> 
>>>>> Same for cfs_time_shift_64()
>>>> 
>>>> Reviewed-by: James Simmons <jsimmons@infradead.org>
>>> 
>>> Hmm, I thought we were trying to get rid of direct HZ usage in modules,
>>> because of tickless systems, and move to e.g. msecs_to_jiffies() or similar?
>> 
>> Are we?  I hadn't heard but I could easily have missed it.
>> Documentation/scheduler/completion.txt does say
>> 
>>    Timeouts are preferably calculated with
>>    msecs_to_jiffies() or usecs_to_jiffies().
>> 
>> but is isn't clear what they are preferred to.  Do you remember where
>> you heard? or have a reference?
>
> I thought the goal was to avoid hard-coding the HZ value so that kernels
> could have variable clock rates in the future.

It is hard to imagine it ever being possible to change, at runtime, the
length of time represented by one jiffie.
Durations, measured in jiffies, are stored it lots of different places,
and they would all need to be changed to msecs - very error prone work.
I think it would be much more likely to set HZ to some large value, and
have the clock tick at varying multiples of that.  The NOHZ work already
does something a bit like that I think.

Thanks,
NeilBrown

>
> Cheers, Andreas
>
>> $ git grep ' \* *HZ'  |wc
>>   2244   15679  170016
>> $ git grep msecs_to_jiffies | wc
>>   3301   13151  276725
>> 
>> so msecs_to_jiffies is slightly more popular than "* HZ" (even if you add
>> in "HZ *").  But that could just be a preference for using milliseconds
>> over using seconds.
>> 
>> $ git grep msecs_to_jiffies   | grep -c '[0-9]000'
>> 587
>> 
>> so there are only 587 places that msecs_to_jiffies is clearly used in
>> place of multiplying by HZ.
>> 
>> If we were to pursue this, I would want to add secs_to_jiffies() to
>> include/linux/jiffies.h and use that.
>> 
>> Thanks,
>> NeilBrown
>> _______________________________________________
>> lustre-devel mailing list
>> lustre-devel at lists.lustre.org
>> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
>
> Cheers, Andreas
> --
> Andreas Dilger
> Lustre Principal Architect
> Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180405/68260140/attachment.sig>

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 08/17] staging: lustre: add container_of_safe()
  2018-03-30 18:59     ` [lustre-devel] " James Simmons
  (?)
@ 2018-04-10  1:37     ` Cory Spitz
  2018-04-11 21:19       ` NeilBrown
  -1 siblings, 1 reply; 86+ messages in thread
From: Cory Spitz @ 2018-04-10  1:37 UTC (permalink / raw)
  To: lustre-devel

James, you misspelled Lustre!



On 3/30/18, 2:00 PM, "lustre-devel on behalf of James Simmons" <lustre-devel-bounces at lists.lustre.org on behalf of jsimmons@infradead.org> wrote:



    > Luster has a container_of0() function which is similar to


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180410/ef51d2d5/attachment.html>

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 08/17] staging: lustre: add container_of_safe()
  2018-04-10  1:37     ` Cory Spitz
@ 2018-04-11 21:19       ` NeilBrown
  0 siblings, 0 replies; 86+ messages in thread
From: NeilBrown @ 2018-04-11 21:19 UTC (permalink / raw)
  To: lustre-devel

On Tue, Apr 10 2018, Cory Spitz wrote:

> James, you misspelled Lustre!

That wasn't James, that was me - sorry :-)

NeilBrown


>
>
>
> On 3/30/18, 2:00 PM, "lustre-devel on behalf of James Simmons" <lustre-devel-bounces at lists.lustre.org on behalf of jsimmons@infradead.org> wrote:
>
>
>
>     > Luster has a container_of0() function which is similar to
>
>
> _______________________________________________
> lustre-devel mailing list
> lustre-devel at lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180412/60cc143a/attachment.sig>

^ permalink raw reply	[flat|nested] 86+ messages in thread

* Re: [PATCH 08/17] staging: lustre: add container_of_safe()
  2018-03-29  4:26   ` [lustre-devel] " NeilBrown
@ 2018-04-23 13:16     ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 86+ messages in thread
From: Greg Kroah-Hartman @ 2018-04-23 13:16 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, James Simmons, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List

On Thu, Mar 29, 2018 at 03:26:48PM +1100, NeilBrown wrote:
> Luster has a container_of0() function which is similar to
> container_of() but passes an IS_ERR_OR_NULL() pointer through
> unchanged.
> This could be generally useful: bcache at last has a similar function.
> 
> Naming is hard, but the precedent set by hlist_entry_safe() suggests
> a _safe suffix might be most consistent.
> 
> So add container_of_safe() to kernel.h, and replace all occurrences of
> container_of0() with one of
>   - list_first_entry, list_next_entry, when that is a better fit,
>   - container_of(), when the pointer is used as a validpointer in
>     surrounding code,
>   - container_of_safe() when there is no obviously better alternative.

I'm loath to add a kernel.h define for a staging driver, but this does
seem sane.  Nice work.

greg k-h

^ permalink raw reply	[flat|nested] 86+ messages in thread

* [lustre-devel] [PATCH 08/17] staging: lustre: add container_of_safe()
@ 2018-04-23 13:16     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 86+ messages in thread
From: Greg Kroah-Hartman @ 2018-04-23 13:16 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, James Simmons, Andreas Dilger,
	Linux Kernel Mailing List, Lustre Development List

On Thu, Mar 29, 2018 at 03:26:48PM +1100, NeilBrown wrote:
> Luster has a container_of0() function which is similar to
> container_of() but passes an IS_ERR_OR_NULL() pointer through
> unchanged.
> This could be generally useful: bcache at last has a similar function.
> 
> Naming is hard, but the precedent set by hlist_entry_safe() suggests
> a _safe suffix might be most consistent.
> 
> So add container_of_safe() to kernel.h, and replace all occurrences of
> container_of0() with one of
>   - list_first_entry, list_next_entry, when that is a better fit,
>   - container_of(), when the pointer is used as a validpointer in
>     surrounding code,
>   - container_of_safe() when there is no obviously better alternative.

I'm loath to add a kernel.h define for a staging driver, but this does
seem sane.  Nice work.

greg k-h

^ permalink raw reply	[flat|nested] 86+ messages in thread

end of thread, other threads:[~2018-04-23 13:16 UTC | newest]

Thread overview: 86+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-29  4:26 [PATCH 00/17] staging: Assorted lustre cleanup NeilBrown
2018-03-29  4:26 ` [lustre-devel] " NeilBrown
2018-03-29  4:26 ` [PATCH 05/17] staging: lustre: remove unneeded include NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 18:57   ` James Simmons
2018-03-30 18:57     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 11/17] staging: lustre: libcfs: discard cfs_time_shift() NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 19:02   ` James Simmons
2018-03-30 19:02     ` [lustre-devel] " James Simmons
2018-04-02 19:34     ` Dilger, Andreas
2018-04-02 19:34       ` [lustre-devel] " Dilger, Andreas
2018-04-02 22:26       ` NeilBrown
2018-04-02 22:26         ` [lustre-devel] " NeilBrown
2018-04-04  8:10         ` Dilger, Andreas
2018-04-04  8:10           ` Dilger, Andreas
2018-04-04 22:00           ` NeilBrown
2018-04-04 22:00             ` NeilBrown
2018-03-29  4:26 ` [PATCH 17/17] staging: lustre: remove cruft from libcfs/linux/libcfs.h NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 19:07   ` James Simmons
2018-03-30 19:07     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 07/17] staging: lustre: ldlm: free resource when ldlm_lock_create() fails NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 18:58   ` James Simmons
2018-03-30 18:58     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 01/17] staging: lustre: remove invariant in cl_io_read_ahead() NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 18:56   ` James Simmons
2018-03-30 18:56     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 02/17] staging: lustre: remove unused ldlm_completion_ast_async() NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 18:57   ` James Simmons
2018-03-30 18:57     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 04/17] staging: lustre: remove unused hash tables NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 18:57   ` James Simmons
2018-03-30 18:57     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 03/17] staging: lustre: LNET excludes USERIO NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 19:09   ` James Simmons
2018-03-30 19:09     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 10/17] staging: lustre: libcfs: discard cfs_time_add/sub NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 19:00   ` James Simmons
2018-03-30 19:00     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 13/17] staging: lustre: libcfs: remove cfs_timeout_cap() NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 19:03   ` James Simmons
2018-03-30 19:03     ` [lustre-devel] " James Simmons
2018-04-02 19:38   ` Dilger, Andreas
2018-04-02 19:38     ` [lustre-devel] " Dilger, Andreas
2018-04-02 22:34     ` NeilBrown
2018-04-02 22:34       ` [lustre-devel] " NeilBrown
2018-03-29  4:26 ` [PATCH 14/17] staging: lustre: discard cfs_duration_sec() NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 19:02   ` James Simmons
2018-03-30 19:02     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 08/17] staging: lustre: add container_of_safe() NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 18:59   ` James Simmons
2018-03-30 18:59     ` [lustre-devel] " James Simmons
2018-04-10  1:37     ` Cory Spitz
2018-04-11 21:19       ` NeilBrown
2018-04-23 13:16   ` Greg Kroah-Hartman
2018-04-23 13:16     ` [lustre-devel] " Greg Kroah-Hartman
2018-03-29  4:26 ` [PATCH 09/17] staging: lustre: cfs_time_current() -> jiffies NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 19:00   ` James Simmons
2018-03-30 19:00     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 16/17] staging: lustre: discard linux-time.h NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 19:03   ` James Simmons
2018-03-30 19:03     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 12/17] staging: lustre: libcfs: discard cfs_time_after() NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 19:01   ` James Simmons
2018-03-30 19:01     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 06/17] staging: lustre: tidy up ldlm_resource_putref() NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 18:58   ` James Simmons
2018-03-30 18:58     ` [lustre-devel] " James Simmons
2018-03-29  4:26 ` [PATCH 15/17] staging: lustre: discard cfs_time_before_64() NeilBrown
2018-03-29  4:26   ` [lustre-devel] " NeilBrown
2018-03-30 19:03   ` James Simmons
2018-03-30 19:03     ` [lustre-devel] " James Simmons

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.