From 6fc61eea18e7fb48734ffef8aee4faa283f05e36 Mon Sep 17 00:00:00 2001
From: shadow <shadow>
Date: Thu, 7 Aug 2008 16:52:08 +0000
Subject: [PATCH] acl includes and time_t formats cleanup.

Branch HEAD
b=14929
i=rread
i=panda
---
 lustre/autoconf/lustre-core.m4    |  2 +-
 lustre/cmm/cmm_internal.h         |  2 +-
 lustre/include/linux/lustre_acl.h | 10 +++++---
 lustre/include/lustre_acl.h       | 35 ++++++++++++++++++++++++++
 lustre/ldlm/ldlm_request.c        | 13 ++++++----
 lustre/llite/llite_internal.h     | 12 +--------
 lustre/llite/xattr.c              |  2 +-
 lustre/lmv/lmv_obd.c              |  5 ----
 lustre/mdc/mdc_locks.c            |  2 +-
 lustre/mdc/mdc_request.c          |  2 +-
 lustre/mdd/mdd_internal.h         |  2 +-
 lustre/mds/handler.c              |  2 +-
 lustre/mdt/mdt_handler.c          |  2 +-
 lustre/mdt/mdt_open.c             |  2 +-
 lustre/obdclass/acl.c             |  2 +-
 lustre/obdclass/genops.c          |  2 +-
 lustre/ptlrpc/client.c            | 26 +++++++++++---------
 lustre/ptlrpc/layout.c            |  2 +-
 lustre/ptlrpc/pack_generic.c      |  2 +-
 lustre/ptlrpc/service.c           | 41 ++++++++++++++++++-------------
 20 files changed, 103 insertions(+), 65 deletions(-)
 create mode 100644 lustre/include/lustre_acl.h

diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index 146f0abda1..c0e3a41f76 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -1401,7 +1401,7 @@ AC_TRY_RUN([
 #  endif
 # endif
 
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 
 #include <stdio.h>
 
diff --git a/lustre/cmm/cmm_internal.h b/lustre/cmm/cmm_internal.h
index a71420b491..e3b1da2148 100644
--- a/lustre/cmm/cmm_internal.h
+++ b/lustre/cmm/cmm_internal.h
@@ -48,7 +48,7 @@
 #include <obd.h>
 #include <lustre_fld.h>
 #include <md_object.h>
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 
 
 struct cmm_device {
diff --git a/lustre/include/linux/lustre_acl.h b/lustre/include/linux/lustre_acl.h
index ba7abb1630..f5d07a55d6 100644
--- a/lustre/include/linux/lustre_acl.h
+++ b/lustre/include/linux/lustre_acl.h
@@ -39,8 +39,12 @@
  * See also lustre_idl.h for wire formats of requests.
  */
 
-#ifndef _LUSTRE_ACL_H
-#define _LUSTRE_ACL_H
+#ifndef _LUSTRE_LINUX_ACL_H
+#define _LUSTRE_LINUX_ACL_H
+
+#ifndef	_LUSTRE_ACL_H
+#error	Shoud not include direectly. use #include <lustre/lustre_acl.h> instead
+#endif
 
 #ifdef __KERNEL__
 # include <linux/fs.h>
@@ -78,4 +82,4 @@
 # define LUSTRE_POSIX_ACL_MAX_SIZE      0
 # endif /* CONFIG_FS_POSIX_ACL */
 
-#endif /* _LUSTRE_ACL_H */
+#endif /* _LUSTRE_LINUX_ACL_H */
diff --git a/lustre/include/lustre_acl.h b/lustre/include/lustre_acl.h
new file mode 100644
index 0000000000..8204adc702
--- /dev/null
+++ b/lustre/include/lustre_acl.h
@@ -0,0 +1,35 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  Copyright (C) 2001 Cluster File Systems, Inc. <info@clusterfs.com>
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
+ *
+ *   Lustre is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2 of the GNU General Public
+ *   License as published by the Free Software Foundation.
+ *
+ *   Lustre 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 for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with Lustre; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifndef _LUSTRE_ACL_H
+#define _LUSTRE_ACL_H
+
+#if defined(__linux__)
+#include <linux/lustre_acl.h>
+#elif defined(__APPLE__)
+#include <darwin/lustre_acl.h>
+#elif defined(__WINNT__)
+#include <winnt/lustre_acl.h>
+#error Unsupported operating system.
+#endif
+
+#endif
diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c
index b54e767cca..5011d59de3 100644
--- a/lustre/ldlm/ldlm_request.c
+++ b/lustre/ldlm/ldlm_request.c
@@ -81,8 +81,8 @@ int ldlm_expired_completion_wait(void *data)
 			   CFS_DURATION_T"s ago); not entering recovery in "
                            "server code, just going back to sleep",
 			   lock->l_enqueued_time.tv_sec,
-                           cfs_time_current_sec() -
-                           lock->l_enqueued_time.tv_sec);
+                           cfs_time_sub(cfs_time_current_sec(),
+                           lock->l_enqueued_time.tv_sec));
                 if (cfs_time_after(cfs_time_current(), next_dump)) {
                         last_dump = next_dump;
                         next_dump = cfs_time_shift(300);
@@ -100,7 +100,8 @@ int ldlm_expired_completion_wait(void *data)
         LDLM_ERROR(lock, "lock timed out (enqueued at "CFS_TIME_T", "
                   CFS_DURATION_T"s ago), entering recovery for %s@%s",
                   lock->l_enqueued_time.tv_sec,
-                  cfs_time_current_sec() - lock->l_enqueued_time.tv_sec,
+                  cfs_time_sub(cfs_time_current_sec(),
+                  lock->l_enqueued_time.tv_sec),
                   obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid);
 
         RETURN(0);
@@ -206,8 +207,10 @@ noreproc:
                 RETURN(rc);
         }
 
-        LDLM_DEBUG(lock, "client-side enqueue waking up: granted after %lds",
-                   cfs_time_current_sec() - lock->l_enqueued_time.tv_sec);
+        LDLM_DEBUG(lock, "client-side enqueue waking up: granted after "
+                   CFS_DURATION_T"s",
+                   cfs_time_sub(cfs_time_current_sec(),
+                   lock->l_enqueued_time.tv_sec));
 
         /* Update our time estimate */
         at_add(&lock->l_resource->lr_namespace->ns_at_estimate,
diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h
index 9f5e7b587a..c9acb96deb 100644
--- a/lustre/llite/llite_internal.h
+++ b/lustre/llite/llite_internal.h
@@ -37,17 +37,7 @@
 #ifndef LLITE_INTERNAL_H
 #define LLITE_INTERNAL_H
 
-#include <linux/lustre_acl.h>
-
-#ifdef CONFIG_FS_POSIX_ACL
-# include <linux/fs.h>
-#ifdef HAVE_XATTR_ACL
-# include <linux/xattr_acl.h>
-#endif /* HAVE_XATTR_ACL */
-#ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
-# include <linux/posix_acl_xattr.h>
-#endif /* HAVE_LINUX_POSIX_ACL_XATTR_H */
-#endif /* CONFIG_FS_POSIX_ACL */
+#include <lustre_acl.h>
 
 #include <lustre_debug.h>
 #include <lustre_ver.h>
diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c
index b33f051e44..28075a9f9c 100644
--- a/lustre/llite/xattr.c
+++ b/lustre/llite/xattr.c
@@ -46,7 +46,7 @@
 #include <lustre_dlm.h>
 #include <lustre_ver.h>
 //#include <lustre_mdc.h>
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 
 #include "llite_internal.h"
 
diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c
index 6b838e3a90..db0116c2d5 100644
--- a/lustre/lmv/lmv_obd.c
+++ b/lustre/lmv/lmv_obd.c
@@ -63,11 +63,6 @@
 #include <lustre_fid.h>
 #include "lmv_internal.h"
 
-/* not defined for liblustre building */
-#if !defined(ATOMIC_INIT)
-#define ATOMIC_INIT(val) { (val) }
-#endif
-
 /* object cache. */
 cfs_mem_cache_t *obj_cache;
 atomic_t obj_cache_count = ATOMIC_INIT(0);
diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c
index 8f0f6d6b86..ea03789001 100644
--- a/lustre/mdc/mdc_locks.c
+++ b/lustre/mdc/mdc_locks.c
@@ -48,7 +48,7 @@
 # include <liblustre.h>
 #endif
 
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 #include <obd_class.h>
 #include <lustre_dlm.h>
 /* fid_res_name_eq() */
diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c
index 10459b39c6..19781c463a 100644
--- a/lustre/mdc/mdc_request.c
+++ b/lustre/mdc/mdc_request.c
@@ -48,7 +48,7 @@
 # include <liblustre.h>
 #endif
 
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 #include <obd_class.h>
 #include <lustre_dlm.h>
 #include <lustre_fid.h>
diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h
index 6ddc808909..01fb5c7ecf 100644
--- a/lustre/mdd/mdd_internal.h
+++ b/lustre/mdd/mdd_internal.h
@@ -43,7 +43,7 @@
 
 #include <asm/semaphore.h>
 
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 #include <lustre_eacl.h>
 #include <obd.h>
 #include <md_object.h>
diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index 961590d0bb..2c37cc549e 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -54,7 +54,7 @@
 #include <linux/workqueue.h>
 #include <linux/mount.h>
 
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 #include <obd_class.h>
 #include <lustre_dlm.h>
 #include <obd_lov.h>
diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c
index 749d1e5d0c..8f060beae6 100644
--- a/lustre/mdt/mdt_handler.c
+++ b/lustre/mdt/mdt_handler.c
@@ -67,7 +67,7 @@
 #include <lustre_mds.h>
 #include <lustre_mdt.h>
 #include "mdt_internal.h"
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 #include <lustre_param.h>
 
 mdl_mode_t mdt_mdl_lock_modes[] = {
diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c
index a07e0a72f0..d197eb647e 100644
--- a/lustre/mdt/mdt_open.c
+++ b/lustre/mdt/mdt_open.c
@@ -45,7 +45,7 @@
 #endif
 #define DEBUG_SUBSYSTEM S_MDS
 
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 #include <lustre_mds.h>
 #include "mdt_internal.h"
 
diff --git a/lustre/obdclass/acl.c b/lustre/obdclass/acl.c
index 07364bcb60..05b1fb0d15 100644
--- a/lustre/obdclass/acl.c
+++ b/lustre/obdclass/acl.c
@@ -46,7 +46,7 @@
 
 #define DEBUG_SUBSYSTEM S_SEC
 
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 #include <lustre_eacl.h>
 #include <obd_support.h>
 
diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c
index aa61ab365c..4ea1aebbe4 100644
--- a/lustre/obdclass/genops.c
+++ b/lustre/obdclass/genops.c
@@ -1072,7 +1072,7 @@ static void class_disconnect_export_list(struct list_head *list, int flags)
                 spin_unlock(&fake_exp->exp_lock);
 
                 CDEBUG(D_HA, "%s: disconnecting export at %s (%p), "
-                       "last request at %ld\n",
+                       "last request at "CFS_TIME_T"\n",
                        exp->exp_obd->obd_name, obd_export_nid2str(exp),
                        exp, exp->exp_last_request_time);
                 rc = obd_disconnect(fake_exp);
diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c
index f0b0c985be..b1a3c106f2 100644
--- a/lustre/ptlrpc/client.c
+++ b/lustre/ptlrpc/client.c
@@ -279,8 +279,9 @@ static void ptlrpc_at_adj_net_latency(struct ptlrpc_request *req)
         /* Network latency is total time less server processing time */
         nl = max_t(int, now - req->rq_sent - st, 0) + 1/*st rounding*/;
         if (st > now - req->rq_sent + 2 /* rounding */)
-                CERROR("Reported service time %u > total measured time %ld\n",
-                       st, now - req->rq_sent);
+                CERROR("Reported service time %u > total measured time "
+                       CFS_DURATION_T"\n",
+                       st, cfs_time_sub(now, req->rq_sent));
 
         oldnl = at_add(&at->iat_net_latency, nl);
         if (oldnl != 0)
@@ -347,9 +348,10 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) {
                     ptlrpc_at_get_net_latency(req);
 
         DEBUG_REQ(D_ADAPTTO, req,
-                  "Early reply #%d, new deadline in %lds (%+lds)",
-                  req->rq_early_count, req->rq_deadline -
-                  cfs_time_current_sec(), req->rq_deadline - olddl);
+                  "Early reply #%d, new deadline in "CFS_DURATION_T"s ("
+                  CFS_DURATION_T"s)", req->rq_early_count,
+                  cfs_time_sub(req->rq_deadline, cfs_time_current_sec()),
+                  cfs_time_sub(req->rq_deadline, olddl));
 
 out_cleanup:
         sptlrpc_cli_finish_early_reply(req);
@@ -1399,17 +1401,19 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req)
         ENTRY;
 
         DEBUG_REQ(D_ERROR|D_NETERROR, req,
-                  "%s (sent at %lu, "CFS_DURATION_T"s ago)",
+                  "%s (sent at "CFS_TIME_T", "CFS_DURATION_T"s ago)",
                   req->rq_net_err ? "network error" : "timeout",
-                  (long)req->rq_sent, cfs_time_current_sec() - req->rq_sent);
+                  req->rq_sent, cfs_time_sub(cfs_time_current_sec(),
+                  req->rq_sent));
 
         if (imp) {
-                LCONSOLE_WARN("Request x"LPU64" sent from %s to NID %s %lus ago"
-                              " has timed out (limit %lus).\n", req->rq_xid,
+                LCONSOLE_WARN("Request x"LPU64" sent from %s to NID %s "
+                              CFS_DURATION_T"s ago has timed out "
+                              "(limit "CFS_DURATION_T"s).\n", req->rq_xid,
                               req->rq_import->imp_obd->obd_name,
                               libcfs_nid2str(imp->imp_connection->c_peer.nid),
-                              cfs_time_current_sec() - req->rq_sent,
-                              req->rq_deadline - req->rq_sent);
+                              cfs_time_sub(cfs_time_current_sec(), req->rq_sent),
+                              cfs_time_sub(req->rq_deadline, req->rq_sent));
         }
 
         if (imp != NULL && obd_debug_peer_on_timeout)
diff --git a/lustre/ptlrpc/layout.c b/lustre/ptlrpc/layout.c
index c522df020d..c11e836fed 100644
--- a/lustre/ptlrpc/layout.c
+++ b/lustre/ptlrpc/layout.c
@@ -66,7 +66,7 @@
 #endif
 /* struct ptlrpc_request, lustre_msg* */
 #include <lustre_req_layout.h>
-#include <linux/lustre_acl.h>
+#include <lustre_acl.h>
 
 /*
  * empty set of fields... for suitable definition of emptiness.
diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c
index 564a6c2064..a60acbc29f 100644
--- a/lustre/ptlrpc/pack_generic.c
+++ b/lustre/ptlrpc/pack_generic.c
@@ -2190,7 +2190,7 @@ void _debug_req(struct ptlrpc_request *req, __u32 mask,
         libcfs_debug_vmsg2(data->msg_cdls, data->msg_subsys, mask, data->msg_file,
                            data->msg_fn, data->msg_line, fmt, args,
                            " req@%p x"LPD64"/t"LPD64"("LPD64") o%d->%s@%s:%d/%d"
-                           " lens %d/%d e %d to %d dl %ld ref %d "
+                           " lens %d/%d e %d to %d dl "CFS_TIME_T" ref %d "
                            "fl "REQ_FLAGS_FMT"/%x/%x rc %d/%d\n",
                            req, req->rq_xid, req->rq_transno,
                            req->rq_reqmsg ? lustre_msg_get_transno(req->rq_reqmsg) : 0,
diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c
index fa23b912af..9c96628b74 100644
--- a/lustre/ptlrpc/service.c
+++ b/lustre/ptlrpc/service.c
@@ -670,8 +670,8 @@ static int ptlrpc_at_add_timed(struct ptlrpc_request *req)
         if ((lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT) == 0)
                 return(-ENOSYS);
 
-        DEBUG_REQ(D_ADAPTTO, req, "add timed %lds",
-                  req->rq_deadline - cfs_time_current_sec());
+        DEBUG_REQ(D_ADAPTTO, req, "add timed "CFS_DURATION_T"s",
+                  cfs_time_sub(req->rq_deadline, cfs_time_current_sec()));
 
         spin_lock(&svc->srv_at_lock);
 
@@ -711,7 +711,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req,
         struct ptlrpc_service *svc = req->rq_rqbd->rqbd_service;
         struct ptlrpc_request *reqcopy;
         struct lustre_msg *reqmsg;
-        long olddl = req->rq_deadline - cfs_time_current_sec();
+        cfs_duration_t olddl = req->rq_deadline - cfs_time_current_sec();
         time_t newdl;
         int rc;
         ENTRY;
@@ -753,9 +753,10 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req,
         if (req->rq_deadline >= newdl) {
                 /* We're not adding any time, no need to send an early reply
                    (e.g. maybe at adaptive_max) */
-                CDEBUG(D_ADAPTTO, "x"LPU64": Couldn't add any time (%ld/%ld), "
+                CDEBUG(D_ADAPTTO, "x"LPU64": Couldn't add any time ("
+                       CFS_DURATION_T"/"CFS_DURATION_T"), "
                        "not sending early reply\n", req->rq_xid, olddl,
-                       newdl - cfs_time_current_sec());
+                       cfs_time_sub(newdl, cfs_time_current_sec()));
                 RETURN(-ETIMEDOUT);
         }
 
@@ -1000,8 +1001,9 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service *svc)
 
         /* req_in handling should/must be fast */
         if (cfs_time_current_sec() - req->rq_arrival_time.tv_sec > 5)
-                DEBUG_REQ(D_WARNING, req, "Slow req_in handling %lus",
-                          cfs_time_current_sec() - req->rq_arrival_time.tv_sec);
+                DEBUG_REQ(D_WARNING, req, "Slow req_in handling "CFS_DURATION_T"s",
+                          cfs_time_sub(cfs_time_current_sec(),
+                                       req->rq_arrival_time.tv_sec));
 
         /* Set rpc server deadline and add it to the timed list */
         deadline = (lustre_msghdr_get_flags(req->rq_reqmsg) &
@@ -1112,11 +1114,12 @@ ptlrpc_server_handle_request(struct ptlrpc_service *svc,
            The deadline is increased if we send an early reply. */
         if (cfs_time_current_sec() > request->rq_deadline) {
                 DEBUG_REQ(D_ERROR, request, "Dropping timed-out request from %s"
-                          ": deadline %ld%+lds ago\n",
+                          ": deadline "CFS_DURATION_T":"CFS_DURATION_T"s ago\n",
                           libcfs_id2str(request->rq_peer),
-                          request->rq_deadline -
-                          request->rq_arrival_time.tv_sec,
-                          cfs_time_current_sec() - request->rq_deadline);
+                          cfs_time_sub(request->rq_deadline,
+                          request->rq_arrival_time.tv_sec),
+                          cfs_time_sub(cfs_time_current_sec(),
+                          request->rq_deadline));
                 goto put_rpc_export;
         }
 
@@ -1160,10 +1163,12 @@ put_conn:
 
         if (unlikely(cfs_time_current_sec() > request->rq_deadline)) {
                 DEBUG_REQ(D_WARNING, request, "Request x"LPU64" took longer "
-                          "than estimated (%ld%+lds); client may timeout.",
-                          request->rq_xid, request->rq_deadline -
-                          request->rq_arrival_time.tv_sec,
-                          cfs_time_current_sec() - request->rq_deadline);
+                          "than estimated ("CFS_DURATION_T":"CFS_DURATION_T"s);"
+                          " client may timeout.",
+                          request->rq_xid, cfs_time_sub(request->rq_deadline,
+                          request->rq_arrival_time.tv_sec),
+                          cfs_time_sub(cfs_time_current_sec(),
+                          request->rq_deadline));
         }
 
         do_gettimeofday(&work_end);
@@ -1189,9 +1194,11 @@ put_conn:
         }
         if (unlikely(request->rq_early_count)) {
                 DEBUG_REQ(D_ADAPTTO, request,
-                          "sent %d early replies before finishing in %lds",
+                          "sent %d early replies before finishing in "
+                          CFS_DURATION_T"s",
                           request->rq_early_count,
-                          work_end.tv_sec - request->rq_arrival_time.tv_sec);
+                          cfs_time_sub(work_end.tv_sec,
+                          request->rq_arrival_time.tv_sec));
         }
 
 out_req:
-- 
GitLab