Whamcloud - gitweb
Silence most of the warnings in the x86_64 build, and kill some Real Bugs in
authorzab <zab>
Thu, 13 Nov 2003 20:21:48 +0000 (20:21 +0000)
committerzab <zab>
Thu, 13 Nov 2003 20:21:48 +0000 (20:21 +0000)
the process.  (sanity checked in an x86 uml build, as well)

- include linux/init.h from some modules that use __init and company
- x86_64 has 64 bit longs but uses 'long long' for u64 in the kernel.  we
  add its own specific section to LP*64 definitions.  Sadly, there are still
  a huge number of warnings from this gcc when we try to LP*64 print uint64_t
  obdo arguments.
- use min_t in some defines to avoid the duplicate const prefacing that comes
  with nesting min()
- LPX64 printing -1UL doesn't work so well
- i_nlink can be any of unsigned short, int, or long.  when printing cast
  to unsigned long.
- kern_addr_valid takes a 'unsigned long' argument and shifts it.. sigh.
- don't #define EXPORT_SYMTAB in the source, that's the job of the kernel
  makefiles
- x86_64/suse has THREAD_SIZE defined in userspace
- s/long flags/unsigned long flags/.  Again.
- va_list ap = NULL; is not legal, as far as I know.  it doesn't seem
  to actually do anything in this code path either.
- x86_64 passes CONFIG_X86 but had thread->rsp as the stack pointer.  this
  code is going away eventually anyway.
- print a pointer with %p, not %x
- some portals callback pointer definitions used size_t while some nal's
  functions used ptl_size_t in the function defintions.  I switched the
  functions over to avoid pushing changes on all the nals.

18 files changed:
lnet/include/linux/kp30.h
lnet/klnds/toelnd/toenal.c
lnet/klnds/toelnd/toenal_cb.c
lnet/libcfs/debug.c
lnet/ulnds/procapi.c
lnet/ulnds/proclib.c
lnet/ulnds/socklnd/procapi.c
lnet/ulnds/socklnd/proclib.c
lnet/ulnds/socklnd/tcplnd.c
lnet/ulnds/tcplnd.c
lustre/ldlm/ldlm_lib.c
lustre/portals/include/linux/kp30.h
lustre/portals/knals/toenal/toenal.c
lustre/portals/knals/toenal/toenal_cb.c
lustre/portals/libcfs/debug.c
lustre/portals/unals/procapi.c
lustre/portals/unals/proclib.c
lustre/portals/unals/tcpnal.c

index f3d0d61..4b95b6c 100644 (file)
@@ -74,8 +74,10 @@ extern unsigned int portal_cerror;
 
 #ifdef __KERNEL__
 # include <linux/sched.h> /* THREAD_SIZE */
-#else
-# define THREAD_SIZE 8192
+#else 
+# ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */
+#  define THREAD_SIZE 8192
+# endif
 #endif
 
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
@@ -1108,14 +1110,19 @@ void kportal_put_ni (int nal);
 # endif
 #endif
 
-#if (BITS_PER_LONG == 32 || __WORDSIZE == 32)
+#if defined(__x86_64__)
+# define LPU64 "%Lu"
+# define LPD64 "%Ld"
+# define LPX64 "%#Lx"
+# define LPSZ  "%lu"
+# define LPSSZ "%ld"
+#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32)
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
 # define LPSZ  "%u"
 # define LPSSZ "%d"
-#endif
-#if (BITS_PER_LONG == 64 || __WORDSIZE == 64)
+#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64)
 # define LPU64 "%lu"
 # define LPD64 "%ld"
 # define LPX64 "%#lx"
index a85b281..07b93cb 100644 (file)
@@ -210,7 +210,7 @@ error:
 int
 ktoenal_close_sock(ptl_nid_t nid)
 {
-        long               flags;
+        unsigned long     flags;
         ksock_conn_t      *conn;
         LIST_HEAD         (death_row);
         struct list_head  *tmp;
index f7fa794..3af9e33 100644 (file)
@@ -140,7 +140,7 @@ ktoenal_dist(nal_cb_t *nal, ptl_nid_t nid, unsigned long *dist)
 ksock_ltx_t *
 ktoenal_get_ltx (int may_block)
 {
-        long        flags;
+        unsigned long   flags;
         ksock_ltx_t *ltx = NULL;
         
         for (;;)
@@ -268,7 +268,7 @@ ktoenal_recvmsg(struct file *sock, struct iovec *iov, int niov, int toread)
 }
 
 void
-ktoenal_process_transmit (ksock_conn_t *conn, long *irq_flags)
+ktoenal_process_transmit (ksock_conn_t *conn, unsigned long *irq_flags)
 {
         ksock_tx_t *tx = list_entry (conn->ksnc_tx_queue.next, ksock_tx_t, tx_list);
         int         rc;
@@ -358,7 +358,7 @@ ktoenal_process_transmit (ksock_conn_t *conn, long *irq_flags)
 void
 ktoenal_launch_packet (ksock_conn_t *conn, ksock_tx_t *tx)
 {
-        long          flags;
+        unsigned long flags;
         int           nob = tx->tx_nob;
         struct iovec *iov = tx->tx_iov;
         int           niov = 1;
@@ -541,7 +541,7 @@ ktoenal_fmb_callback (void *arg, int error)
         ksock_fmb_t       *fmb = (ksock_fmb_t *)arg;
         ptl_hdr_t         *hdr = (ptl_hdr_t *) page_address(fmb->fmb_pages[0]);
         ksock_conn_t      *conn;
-        long               flags;
+        unsigned long     flags;
 
         CDEBUG (D_NET, "routed packet from "LPX64" to "LPX64": %d\n", 
                 hdr->src_nid, hdr->dest_nid, error);
@@ -790,7 +790,7 @@ ktoenal_new_packet (ksock_conn_t *conn, int nob_to_skip)
 }
 
 void
-ktoenal_process_receive (ksock_conn_t *conn, long *irq_flags)
+ktoenal_process_receive (ksock_conn_t *conn, unsigned long *irq_flags)
 {
         ksock_fmb_t *fmb;
         int          len;
index f27924e..6e2c1ca 100644 (file)
@@ -775,7 +775,6 @@ portals_debug_msg(int subsys, int mask, char *file, const char *fn,
                         /* If this is the first time, leave a marker in the
                          * output */
                         debug_daemon_state.overlapped = 1;
-                        ap = NULL;
                         format = "DEBUG MARKER: Debug buffer overlapped\n";
                         printk(KERN_ERR "LustreError: debug daemon buffer "
                                "overlapped\n");
@@ -982,7 +981,11 @@ extern int lookup_symbol(unsigned long address, char *buf, int buflen);
 
 char *portals_debug_dumpstack(void)
 {
+#if defined(__x86_64__)
+        unsigned long esp = current->thread.rsp;
+#else
         unsigned long esp = current->thread.esp;
+#endif
         unsigned long *stack = (unsigned long *)&esp;
         int size;
         unsigned long addr;
@@ -1012,7 +1015,7 @@ char *portals_debug_dumpstack(void)
                                             /* fix length + sizeof('\0') */
                                     <= pbuf + strlen(buffer) + 28 + 1)
                                         break;
-                                size = sprintf(pbuf, "([<%08lx>] %s (0x%x)) ",
+                                size = sprintf(pbuf, "([<%08lx>] %s (0x%p)) ",
                                                addr, buffer, stack-1);
                         }
                         pbuf += size;
index f4820b2..d897058 100644 (file)
@@ -53,8 +53,8 @@
           lib_fini(b->nal_cb);\
           return(PTL_SEGV);\
        }
-static int procbridge_forward(nal_t *n, int id, void *args, ptl_size_t args_len,
-                             void *ret, ptl_size_t ret_len)
+static int procbridge_forward(nal_t *n, int id, void *args, size_t args_len,
+                             void *ret, size_t ret_len)
 {
     bridge b=(bridge)n->nal_data;
     procbridge p=(procbridge)b->local;
@@ -108,7 +108,7 @@ static int procbridge_shutdown(nal_t *n, int ni)
 /* Function: validate
  *    useless stub
  */
-static int procbridge_validate(nal_t *nal, void *base, ptl_size_t extent)
+static int procbridge_validate(nal_t *nal, void *base, size_t extent)
 {
     return(0);
 }
index 99afe66..89b67ad 100644 (file)
@@ -48,7 +48,7 @@ static int nal_write(nal_cb_t *nal,
                      void *private,
                      user_ptr dst_addr,
                      void *src_addr,
-                     ptl_size_t len)
+                     size_t len)
 {
     memcpy(dst_addr, src_addr, len);
     return 0;
@@ -65,7 +65,7 @@ static int nal_read(nal_cb_t * nal,
 }
 
 static void *nal_malloc(nal_cb_t *nal,
-                        ptl_size_t len)
+                        size_t len)
 {
     void *buf =  malloc(len);
     return buf;
@@ -73,7 +73,7 @@ static void *nal_malloc(nal_cb_t *nal,
 
 static void nal_free(nal_cb_t *nal,
                      void *buf,
-                     ptl_size_t len)
+                     size_t len)
 {
     free(buf);
 }
index f4820b2..d897058 100644 (file)
@@ -53,8 +53,8 @@
           lib_fini(b->nal_cb);\
           return(PTL_SEGV);\
        }
-static int procbridge_forward(nal_t *n, int id, void *args, ptl_size_t args_len,
-                             void *ret, ptl_size_t ret_len)
+static int procbridge_forward(nal_t *n, int id, void *args, size_t args_len,
+                             void *ret, size_t ret_len)
 {
     bridge b=(bridge)n->nal_data;
     procbridge p=(procbridge)b->local;
@@ -108,7 +108,7 @@ static int procbridge_shutdown(nal_t *n, int ni)
 /* Function: validate
  *    useless stub
  */
-static int procbridge_validate(nal_t *nal, void *base, ptl_size_t extent)
+static int procbridge_validate(nal_t *nal, void *base, size_t extent)
 {
     return(0);
 }
index 99afe66..89b67ad 100644 (file)
@@ -48,7 +48,7 @@ static int nal_write(nal_cb_t *nal,
                      void *private,
                      user_ptr dst_addr,
                      void *src_addr,
-                     ptl_size_t len)
+                     size_t len)
 {
     memcpy(dst_addr, src_addr, len);
     return 0;
@@ -65,7 +65,7 @@ static int nal_read(nal_cb_t * nal,
 }
 
 static void *nal_malloc(nal_cb_t *nal,
-                        ptl_size_t len)
+                        size_t len)
 {
     void *buf =  malloc(len);
     return buf;
@@ -73,7 +73,7 @@ static void *nal_malloc(nal_cb_t *nal,
 
 static void nal_free(nal_cb_t *nal,
                      void *buf,
-                     ptl_size_t len)
+                     size_t len)
 {
     free(buf);
 }
index d6b5ed0..5daee9c 100644 (file)
@@ -120,8 +120,8 @@ int tcpnal_recv(nal_cb_t *n,
                lib_msg_t *cookie,
                 unsigned int niov,
                 struct iovec *iov,
-               ptl_size_t mlen,
-               ptl_size_t rlen)
+               size_t mlen,
+               size_t rlen)
 
 {
     if (mlen) {
index d6b5ed0..5daee9c 100644 (file)
@@ -120,8 +120,8 @@ int tcpnal_recv(nal_cb_t *n,
                lib_msg_t *cookie,
                 unsigned int niov,
                 struct iovec *iov,
-               ptl_size_t mlen,
-               ptl_size_t rlen)
+               size_t mlen,
+               size_t rlen)
 
 {
     if (mlen) {
index 106fcb6..7c6aadf 100644 (file)
@@ -291,7 +291,7 @@ int client_disconnect_export(struct obd_export *exp, int failover)
         if (!obd) {
                 CERROR("invalid export for disconnect: "
                        "exp %p cookie "LPX64"\n", exp, 
-                       exp ? exp->exp_handle.h_cookie : -1UL);
+                       exp ? exp->exp_handle.h_cookie : -1);
                 RETURN(-EINVAL);
         }
 
index f3d0d61..4b95b6c 100644 (file)
@@ -74,8 +74,10 @@ extern unsigned int portal_cerror;
 
 #ifdef __KERNEL__
 # include <linux/sched.h> /* THREAD_SIZE */
-#else
-# define THREAD_SIZE 8192
+#else 
+# ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */
+#  define THREAD_SIZE 8192
+# endif
 #endif
 
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
@@ -1108,14 +1110,19 @@ void kportal_put_ni (int nal);
 # endif
 #endif
 
-#if (BITS_PER_LONG == 32 || __WORDSIZE == 32)
+#if defined(__x86_64__)
+# define LPU64 "%Lu"
+# define LPD64 "%Ld"
+# define LPX64 "%#Lx"
+# define LPSZ  "%lu"
+# define LPSSZ "%ld"
+#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32)
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
 # define LPSZ  "%u"
 # define LPSSZ "%d"
-#endif
-#if (BITS_PER_LONG == 64 || __WORDSIZE == 64)
+#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64)
 # define LPU64 "%lu"
 # define LPD64 "%ld"
 # define LPX64 "%#lx"
index a85b281..07b93cb 100644 (file)
@@ -210,7 +210,7 @@ error:
 int
 ktoenal_close_sock(ptl_nid_t nid)
 {
-        long               flags;
+        unsigned long     flags;
         ksock_conn_t      *conn;
         LIST_HEAD         (death_row);
         struct list_head  *tmp;
index f7fa794..3af9e33 100644 (file)
@@ -140,7 +140,7 @@ ktoenal_dist(nal_cb_t *nal, ptl_nid_t nid, unsigned long *dist)
 ksock_ltx_t *
 ktoenal_get_ltx (int may_block)
 {
-        long        flags;
+        unsigned long   flags;
         ksock_ltx_t *ltx = NULL;
         
         for (;;)
@@ -268,7 +268,7 @@ ktoenal_recvmsg(struct file *sock, struct iovec *iov, int niov, int toread)
 }
 
 void
-ktoenal_process_transmit (ksock_conn_t *conn, long *irq_flags)
+ktoenal_process_transmit (ksock_conn_t *conn, unsigned long *irq_flags)
 {
         ksock_tx_t *tx = list_entry (conn->ksnc_tx_queue.next, ksock_tx_t, tx_list);
         int         rc;
@@ -358,7 +358,7 @@ ktoenal_process_transmit (ksock_conn_t *conn, long *irq_flags)
 void
 ktoenal_launch_packet (ksock_conn_t *conn, ksock_tx_t *tx)
 {
-        long          flags;
+        unsigned long flags;
         int           nob = tx->tx_nob;
         struct iovec *iov = tx->tx_iov;
         int           niov = 1;
@@ -541,7 +541,7 @@ ktoenal_fmb_callback (void *arg, int error)
         ksock_fmb_t       *fmb = (ksock_fmb_t *)arg;
         ptl_hdr_t         *hdr = (ptl_hdr_t *) page_address(fmb->fmb_pages[0]);
         ksock_conn_t      *conn;
-        long               flags;
+        unsigned long     flags;
 
         CDEBUG (D_NET, "routed packet from "LPX64" to "LPX64": %d\n", 
                 hdr->src_nid, hdr->dest_nid, error);
@@ -790,7 +790,7 @@ ktoenal_new_packet (ksock_conn_t *conn, int nob_to_skip)
 }
 
 void
-ktoenal_process_receive (ksock_conn_t *conn, long *irq_flags)
+ktoenal_process_receive (ksock_conn_t *conn, unsigned long *irq_flags)
 {
         ksock_fmb_t *fmb;
         int          len;
index f27924e..6e2c1ca 100644 (file)
@@ -775,7 +775,6 @@ portals_debug_msg(int subsys, int mask, char *file, const char *fn,
                         /* If this is the first time, leave a marker in the
                          * output */
                         debug_daemon_state.overlapped = 1;
-                        ap = NULL;
                         format = "DEBUG MARKER: Debug buffer overlapped\n";
                         printk(KERN_ERR "LustreError: debug daemon buffer "
                                "overlapped\n");
@@ -982,7 +981,11 @@ extern int lookup_symbol(unsigned long address, char *buf, int buflen);
 
 char *portals_debug_dumpstack(void)
 {
+#if defined(__x86_64__)
+        unsigned long esp = current->thread.rsp;
+#else
         unsigned long esp = current->thread.esp;
+#endif
         unsigned long *stack = (unsigned long *)&esp;
         int size;
         unsigned long addr;
@@ -1012,7 +1015,7 @@ char *portals_debug_dumpstack(void)
                                             /* fix length + sizeof('\0') */
                                     <= pbuf + strlen(buffer) + 28 + 1)
                                         break;
-                                size = sprintf(pbuf, "([<%08lx>] %s (0x%x)) ",
+                                size = sprintf(pbuf, "([<%08lx>] %s (0x%p)) ",
                                                addr, buffer, stack-1);
                         }
                         pbuf += size;
index f4820b2..d897058 100644 (file)
@@ -53,8 +53,8 @@
           lib_fini(b->nal_cb);\
           return(PTL_SEGV);\
        }
-static int procbridge_forward(nal_t *n, int id, void *args, ptl_size_t args_len,
-                             void *ret, ptl_size_t ret_len)
+static int procbridge_forward(nal_t *n, int id, void *args, size_t args_len,
+                             void *ret, size_t ret_len)
 {
     bridge b=(bridge)n->nal_data;
     procbridge p=(procbridge)b->local;
@@ -108,7 +108,7 @@ static int procbridge_shutdown(nal_t *n, int ni)
 /* Function: validate
  *    useless stub
  */
-static int procbridge_validate(nal_t *nal, void *base, ptl_size_t extent)
+static int procbridge_validate(nal_t *nal, void *base, size_t extent)
 {
     return(0);
 }
index 99afe66..89b67ad 100644 (file)
@@ -48,7 +48,7 @@ static int nal_write(nal_cb_t *nal,
                      void *private,
                      user_ptr dst_addr,
                      void *src_addr,
-                     ptl_size_t len)
+                     size_t len)
 {
     memcpy(dst_addr, src_addr, len);
     return 0;
@@ -65,7 +65,7 @@ static int nal_read(nal_cb_t * nal,
 }
 
 static void *nal_malloc(nal_cb_t *nal,
-                        ptl_size_t len)
+                        size_t len)
 {
     void *buf =  malloc(len);
     return buf;
@@ -73,7 +73,7 @@ static void *nal_malloc(nal_cb_t *nal,
 
 static void nal_free(nal_cb_t *nal,
                      void *buf,
-                     ptl_size_t len)
+                     size_t len)
 {
     free(buf);
 }
index d6b5ed0..5daee9c 100644 (file)
@@ -120,8 +120,8 @@ int tcpnal_recv(nal_cb_t *n,
                lib_msg_t *cookie,
                 unsigned int niov,
                 struct iovec *iov,
-               ptl_size_t mlen,
-               ptl_size_t rlen)
+               size_t mlen,
+               size_t rlen)
 
 {
     if (mlen) {