From: James Simmons Date: Tue, 29 Mar 2016 00:30:55 +0000 (-0400) Subject: LU-6245 libcfs: remove libcfs userland time abstraction X-Git-Tag: 2.8.52~17 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8caff5d019674aea7d98e225d0136bf4694d5157 LU-6245 libcfs: remove libcfs userland time abstraction 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 Reviewed-on: http://review.whamcloud.com/19113 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Frank Zago Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond --- diff --git a/libcfs/include/libcfs/Makefile.am b/libcfs/include/libcfs/Makefile.am index 9015bc4..80deadab 100644 --- a/libcfs/include/libcfs/Makefile.am +++ b/libcfs/include/libcfs/Makefile.am @@ -25,5 +25,4 @@ EXTRA_DIST = \ libcfs_time.h \ libcfs_workitem.h \ list.h \ - types.h \ - user-time.h + types.h diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index a604e01..fa6b84f 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -39,9 +39,7 @@ #include -#ifndef __KERNEL__ -# include -# else /* __KERNEL__ */ +#ifdef __KERNEL__ # include # include # include "curproc.h" @@ -126,9 +124,7 @@ void cfs_get_random_bytes(void *buf, int size); # include # include # include -#endif /* __KERNEL__ */ -#include -#ifdef __KERNEL__ +# include # include # include # include diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index f390367..51fcf28 100644 --- a/libcfs/include/libcfs/libcfs_debug.h +++ b/libcfs/include/libcfs/libcfs_debug.h @@ -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; }; diff --git a/libcfs/include/libcfs/libcfs_time.h b/libcfs/include/libcfs/libcfs_time.h index 6ac5659..0011bf3 100644 --- a/libcfs/include/libcfs/libcfs_time.h +++ b/libcfs/include/libcfs/libcfs_time.h @@ -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 diff --git a/libcfs/include/libcfs/linux/linux-time.h b/libcfs/include/libcfs/linux/linux-time.h index d567711..f39aee1 100644 --- a/libcfs/include/libcfs/linux/linux-time.h +++ b/libcfs/include/libcfs/linux/linux-time.h @@ -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 index d88af2e..0000000 --- a/libcfs/include/libcfs/user-time.h +++ /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 - */ - -#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 -#include -#include -#include -#include -#include - -#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: - */ diff --git a/lnet/utils/debug.c b/lnet/utils/debug.c index 6491541..bd28088 100644 --- a/lnet/utils/debug.c +++ b/lnet/utils/debug.c @@ -60,7 +60,6 @@ #include #include -#include #include #include @@ -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)) { diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c index 6918c37..26efcc6 100644 --- a/lnet/utils/portals.c +++ b/lnet/utils/portals.c @@ -37,7 +37,6 @@ #include #include -#include #include #include #include diff --git a/lustre/tests/group_lock_test.c b/lustre/tests/group_lock_test.c index 1b43580..24562e2 100644 --- a/lustre/tests/group_lock_test.c +++ b/lustre/tests/group_lock_test.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include diff --git a/lustre/tests/sendfile_grouplock.c b/lustre/tests/sendfile_grouplock.c index 80b2da5..5cd8d5e 100644 --- a/lustre/tests/sendfile_grouplock.c +++ b/lustre/tests/sendfile_grouplock.c @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include diff --git a/lustre/utils/liblustreapi_hsm.c b/lustre/utils/liblustreapi_hsm.c index 3536496..d95383a 100644 --- a/lustre/utils/liblustreapi_hsm.c +++ b/lustre/utils/liblustreapi_hsm.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c index b12a2d9..e1f191b 100644 --- a/lustre/utils/lustre_rsync.c +++ b/lustre/utils/lustre_rsync.c @@ -120,6 +120,7 @@ #include #include #include +#include #include #include diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 8bf063a..18ac16c 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -47,7 +47,6 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif -#include "mount_utils.h" #include #include #include @@ -71,9 +70,7 @@ #include #include -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif +#include "mount_utils.h" char *progname; int verbose = 1; diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index 0b9cafd..66ddb21 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -42,9 +42,9 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif -#include "mount_utils.h" #include #include +#include #include #include #include @@ -52,12 +52,15 @@ #include #include #include -#include "obdctl.h" #include #include #include #include #include + +#include "obdctl.h" +#include "mount_utils.h" + #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 10, 53, 0) /* * LU-1783 diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index 828874d..15b0b30 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -38,7 +38,8 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ -#include "mount_utils.h" +#include +#include #include #include #include @@ -53,6 +54,8 @@ #include #include +#include "mount_utils.h" + extern char *progname; extern int verbose; diff --git a/lustre/utils/mount_utils_ldiskfs.c b/lustre/utils/mount_utils_ldiskfs.c index 54b62fe..e350133 100644 --- a/lustre/utils/mount_utils_ldiskfs.c +++ b/lustre/utils/mount_utils_ldiskfs.c @@ -47,12 +47,13 @@ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif -#include "mount_utils.h" -#include +#include #include +#include +#include +#include #include #include -#include #include #include @@ -79,6 +80,8 @@ #include #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" diff --git a/lustre/utils/mount_utils_zfs.c b/lustre/utils/mount_utils_zfs.c index 1ca12ce..b1ca83d 100644 --- a/lustre/utils/mount_utils_zfs.c +++ b/lustre/utils/mount_utils_zfs.c @@ -27,6 +27,7 @@ * Author: Brian Behlendorf */ #include "mount_utils.h" +#include #include #include #include