Whamcloud - gitweb
LU-6245 libcfs: remove libcfs userland time abstraction 13/19113/3
authorJames Simmons <uja.ornl@yahoo.com>
Tue, 29 Mar 2016 00:30:55 +0000 (20:30 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 11 Apr 2016 02:51:48 +0000 (02:51 +0000)
Instead of creating a time abstraction layer in libcfs
for userland lets just use the userland time APIs
directly.

Change-Id: I5c91b23d4ae6c4f75f7712c28572818f26fe57e2
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: http://review.whamcloud.com/19113
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Frank Zago <fzago@cray.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
17 files changed:
libcfs/include/libcfs/Makefile.am
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/libcfs_debug.h
libcfs/include/libcfs/libcfs_time.h
libcfs/include/libcfs/linux/linux-time.h
libcfs/include/libcfs/user-time.h [deleted file]
lnet/utils/debug.c
lnet/utils/portals.c
lustre/tests/group_lock_test.c
lustre/tests/sendfile_grouplock.c
lustre/utils/liblustreapi_hsm.c
lustre/utils/lustre_rsync.c
lustre/utils/mkfs_lustre.c
lustre/utils/mount_lustre.c
lustre/utils/mount_utils.c
lustre/utils/mount_utils_ldiskfs.c
lustre/utils/mount_utils_zfs.c

index 9015bc4..80deada 100644 (file)
@@ -25,5 +25,4 @@ EXTRA_DIST = \
        libcfs_time.h \
        libcfs_workitem.h \
        list.h \
-       types.h \
-       user-time.h
+       types.h
index a604e01..fa6b84f 100644 (file)
@@ -39,9 +39,7 @@
 
 #include <libcfs/list.h>
 
-#ifndef __KERNEL__
-# include <libcfs/user-time.h>
-# else /* __KERNEL__ */
+#ifdef __KERNEL__
 # include <libcfs/linux/libcfs.h>
 # include <libcfs/types.h>
 # include "curproc.h"
@@ -126,9 +124,7 @@ void cfs_get_random_bytes(void *buf, int size);
 # include <libcfs/libcfs_cpu.h>
 # include <libcfs/libcfs_ioctl.h>
 # include <libcfs/libcfs_prim.h>
-#endif /* __KERNEL__ */
-#include <libcfs/libcfs_time.h>
-#ifdef __KERNEL__
+# include <libcfs/libcfs_time.h>
 # include <libcfs/libcfs_string.h>
 # include <libcfs/libcfs_workitem.h>
 # include <libcfs/libcfs_hash.h>
index f390367..51fcf28 100644 (file)
@@ -174,7 +174,7 @@ struct ptldebug_header {
 #define CDEBUG_DEFAULT_MIN_DELAY ((cfs_time_seconds(1) + 1) / 2) /* jiffies */
 #define CDEBUG_DEFAULT_BACKOFF   2
 struct cfs_debug_limit_state {
-       cfs_time_t      cdls_next;
+       unsigned long   cdls_next;
        unsigned int    cdls_delay;
        int             cdls_count;
 };
index 6ac5659..0011bf3 100644 (file)
@@ -82,14 +82,6 @@ static inline long cfs_timeval_sub(struct timeval *large, struct timeval *small,
         return r;
 }
 
-static inline void cfs_slow_warning(cfs_time_t now, int seconds, char *msg)
-{
-        if (cfs_time_after(cfs_time_current(),
-                           cfs_time_add(now, cfs_time_seconds(15))))
-                CERROR("slow %s "CFS_TIME_T" sec\n", msg,
-                       cfs_duration_sec(cfs_time_sub(cfs_time_current(),now)));
-}
-
 #define CFS_RATELIMIT(seconds)                                  \
 ({                                                              \
         /*                                                      \
@@ -118,15 +110,17 @@ static inline void cfs_fs_timeval(struct timeval *tv)
         cfs_fs_time_usec(&time, tv);
 }
 
+#define CFS_TICK       1
+
 /*
  * return valid time-out based on user supplied one. Currently we only check
  * that time-out is not shorted than allowed.
  */
 static inline cfs_duration_t cfs_timeout_cap(cfs_duration_t timeout)
 {
-        if (timeout < CFS_TICK)
-                timeout = CFS_TICK;
-        return timeout;
+       if (timeout < CFS_TICK)
+               timeout = CFS_TICK;
+       return timeout;
 }
 
 #endif
index d567711..f39aee1 100644 (file)
@@ -259,8 +259,6 @@ static inline int cfs_time_beforeq_64(__u64 t1, __u64 t2)
 /*
  * One jiffy
  */
-#define CFS_TICK                (1)
-
 #define CFS_TIME_T              "%lu"
 #define CFS_DURATION_T          "%ld"
 
diff --git a/libcfs/include/libcfs/user-time.h b/libcfs/include/libcfs/user-time.h
deleted file mode 100644 (file)
index d88af2e..0000000
+++ /dev/null
@@ -1,203 +0,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.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * 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/user-time.h
- *
- * Implementation of portable time API for user-level.
- *
- * Author: Nikita Danilov <nikita@clusterfs.com>
- */
-
-#ifndef __LIBCFS_USER_TIME_H__
-#define __LIBCFS_USER_TIME_H__
-
-/* Portable time API */
-
-/*
- * Platform provides three opaque data-types:
- *
- *  cfs_time_t        represents point in time. This is internal kernel
- *                    time rather than "wall clock". This time bears no
- *                    relation to gettimeofday().
- *
- *  cfs_duration_t    represents time interval with resolution of internal
- *                    platform clock
- *
- *  cfs_fs_time_t     represents instance in world-visible time. This is
- *                    used in file-system time-stamps
- *
- *  cfs_time_t     cfs_time_current(void);
- *  cfs_time_t     cfs_time_add    (cfs_time_t, cfs_duration_t);
- *  cfs_duration_t cfs_time_sub    (cfs_time_t, cfs_time_t);
- *  int            cfs_time_before (cfs_time_t, cfs_time_t);
- *  int            cfs_time_beforeq(cfs_time_t, cfs_time_t);
- *
- *  cfs_duration_t cfs_duration_build(int64_t);
- *
- *  time_t         cfs_duration_sec (cfs_duration_t);
- *  void           cfs_duration_usec(cfs_duration_t, struct timeval *);
- *  void           cfs_duration_nsec(cfs_duration_t, struct timespec *);
- *
- *  void           cfs_fs_time_current(cfs_fs_time_t *);
- *  time_t         cfs_fs_time_sec    (cfs_fs_time_t *);
- *  void           cfs_fs_time_usec   (cfs_fs_time_t *, struct timeval *);
- *  void           cfs_fs_time_nsec   (cfs_fs_time_t *, struct timespec *);
- *  int            cfs_fs_time_before (cfs_fs_time_t *, cfs_fs_time_t *);
- *  int            cfs_fs_time_beforeq(cfs_fs_time_t *, cfs_fs_time_t *);
- *
- *  CFS_TIME_FORMAT
- *  CFS_DURATION_FORMAT
- *
- */
-
-#ifndef __KERNEL__
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <sys/time.h>
-#include <time.h>
-
-#define ONE_BILLION ((uint64_t)1000000000)
-#define ONE_MILLION 1000000
-
-/*
- * Liblustre. time(2) based implementation.
- */
-
-typedef time_t cfs_fs_time_t;
-typedef time_t cfs_time_t;
-typedef time_t cfs_duration_t;
-
-#define cfs_time_before(a, b) ((long)(a) - (long)(b) < 0)
-#define cfs_time_beforeq(a, b) ((long)(b) - (long)(a) >= 0)
-
-static inline cfs_time_t cfs_time_current(void)
-{
-        return time(NULL);
-}
-
-static inline cfs_duration_t cfs_time_seconds(cfs_time_t seconds)
-{
-        return seconds;
-}
-
-static inline time_t cfs_time_current_sec(void)
-{
-        return cfs_time_seconds(cfs_time_current());
-}
-
-static inline cfs_duration_t cfs_duration_build(int64_t nano)
-{
-        return (cfs_duration_t) (nano / ONE_BILLION);
-}
-
-static inline time_t cfs_duration_sec(cfs_duration_t d)
-{
-        return d;
-}
-
-static inline void cfs_duration_usec(cfs_duration_t d, struct timeval *s)
-{
-        s->tv_sec = d;
-        s->tv_usec = 0;
-}
-
-static inline void cfs_duration_nsec(cfs_duration_t d, struct timespec *s)
-{
-        s->tv_sec = d;
-        s->tv_nsec = 0;
-}
-
-static inline void cfs_fs_time_current(cfs_fs_time_t *t)
-{
-        time(t);
-}
-
-static inline time_t cfs_fs_time_sec(cfs_fs_time_t *t)
-{
-        return *t;
-}
-
-static inline void cfs_fs_time_usec(cfs_fs_time_t *t, struct timeval *v)
-{
-        v->tv_sec = *t;
-        v->tv_usec = 0;
-}
-
-static inline void cfs_fs_time_nsec(cfs_fs_time_t *t, struct timespec *s)
-{
-        s->tv_sec = *t;
-        s->tv_nsec = 0;
-}
-
-static inline int cfs_fs_time_before(cfs_fs_time_t *t1, cfs_fs_time_t *t2)
-{
-        return *t1 < *t2;
-}
-
-static inline int cfs_fs_time_beforeq(cfs_fs_time_t *t1, cfs_fs_time_t *t2)
-{
-        return *t1 <= *t2;
-}
-
-#define CFS_TICK                (1)
-
-#define cfs_time_current_64 cfs_time_current
-#define cfs_time_add_64     cfs_time_add
-#define cfs_time_shift_64   cfs_time_shift
-#define cfs_time_before_64  cfs_time_before
-#define cfs_time_beforeq_64 cfs_time_beforeq
-
-/* XXX needs to move to arch specific header or configured */
-#ifndef CFS_TIME_T
-#define CFS_TIME_T              "%lu"
-#endif
-
-#define CFS_DURATION_T          "%ld"
-
-/* !__KERNEL__ */
-#endif
-
-/* __LIBCFS_USER_TIME_H__ */
-#endif
-/*
- * Local variables:
- * c-indentation-style: "K&R"
- * c-basic-offset: 8
- * tab-width: 8
- * fill-column: 80
- * scroll-step: 1
- * End:
- */
index 6491541..bd28088 100644 (file)
@@ -60,7 +60,6 @@
 
 #include <libcfs/util/ioctl.h>
 #include <libcfs/util/param.h>
-#include <libcfs/user-time.h>
 #include <libcfs/libcfs_debug.h>
 #include <lnet/lnetctl.h>
 
@@ -535,7 +534,7 @@ int jt_dbg_debug_kernel(int argc, char **argv)
                }
                strncpy(filename, argv[1], sizeof(filename));
        } else {
-               if (snprintf(filename, sizeof(filename), "%s"CFS_TIME_T".%u",
+               if (snprintf(filename, sizeof(filename), "%s%lu.%u",
                             LIBCFS_DEBUG_FILE_PATH_DEFAULT, time(NULL),
                             getpid())
                    >= sizeof(filename)) {
index 6918c37..26efcc6 100644 (file)
@@ -37,7 +37,6 @@
 
 #include <libcfs/util/string.h>
 #include <libcfs/util/ioctl.h>
-#include <libcfs/user-time.h>
 #include <libcfs/libcfs_debug.h>
 #include <lnet/lnetctl.h>
 #include <lnet/socklnd.h>
index 1b43580..24562e2 100644 (file)
@@ -38,6 +38,7 @@
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <time.h>
 #include <unistd.h>
 #include <poll.h>
 
index 80b2da5..5cd8d5e 100644 (file)
@@ -60,6 +60,7 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <time.h>
 #include <unistd.h>
 #include <poll.h>
 #include <sys/sendfile.h>
index 3536496..d95383a 100644 (file)
@@ -46,6 +46,7 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <time.h>
 #include <utime.h>
 #include <sys/syscall.h>
 #include <fnmatch.h>
index b12a2d9..e1f191b 100644 (file)
 #include <errno.h>
 #include <limits.h>
 #include <utime.h>
+#include <time.h>
 #include <sys/xattr.h>
 
 #include <libcfs/util/string.h>
index 8bf063a..18ac16c 100644 (file)
@@ -47,7 +47,6 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
-#include "mount_utils.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -71,9 +70,7 @@
 #include <lnet/lnetctl.h>
 #include <lustre_ver.h>
 
-#ifndef PATH_MAX
-#define PATH_MAX 4096
-#endif
+#include "mount_utils.h"
 
 char *progname;
 int verbose = 1;
index 0b9cafd..66ddb21 100644 (file)
@@ -42,9 +42,9 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
-#include "mount_utils.h"
 #include <getopt.h>
 #include <mntent.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/mount.h>
-#include "obdctl.h"
 #include <lustre_ver.h>
 #include <ctype.h>
 #include <limits.h>
 #include <lnet/nidstr.h>
 #include <lustre/lustre_idl.h>
+
+#include "obdctl.h"
+#include "mount_utils.h"
+
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 10, 53, 0)
 /*
  * LU-1783
index 828874d..15b0b30 100644 (file)
@@ -38,7 +38,8 @@
 #  include "config.h"
 #endif /* HAVE_CONFIG_H */
 
-#include "mount_utils.h"
+#include <inttypes.h>
+#include <limits.h>
 #include <mntent.h>
 #include <stdio.h>
 #include <errno.h>
@@ -53,6 +54,8 @@
 #include <linux/loop.h>
 #include <dlfcn.h>
 
+#include "mount_utils.h"
+
 extern char *progname;
 extern int verbose;
 
index 54b62fe..e350133 100644 (file)
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
-#include "mount_utils.h"
-#include <stdlib.h>
+#include <stdarg.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <stdarg.h>
 #include <mntent.h>
 #include <glob.h>
 
@@ -79,6 +80,8 @@
 #include <selinux/selinux.h>
 #endif
 
+#include "mount_utils.h"
+
 #define MAX_HW_SECTORS_KB_PATH "queue/max_hw_sectors_kb"
 #define MAX_SECTORS_KB_PATH    "queue/max_sectors_kb"
 #define SCHEDULER_PATH         "queue/scheduler"
index 1ca12ce..b1ca83d 100644 (file)
@@ -27,6 +27,7 @@
  * Author: Brian Behlendorf <behlendorf1@llnl.gov>
  */
 #include "mount_utils.h"
+#include <stddef.h>
 #include <stdio.h>
 #include <string.h>
 #include <libzfs.h>