Whamcloud - gitweb
LU-1961 build: fix 'dereference before null check' errors
[fs/lustre-release.git] / lnet / selftest / selftest.h
index 786501d..3540b44 100644 (file)
@@ -27,6 +27,8 @@
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -213,8 +215,8 @@ typedef struct srpc_server_rpc {
 
 /* client-side state of a RPC */
 typedef struct srpc_client_rpc {
-        cfs_list_t           crpc_list;   /* chain on user's lists */
-        cfs_spinlock_t       crpc_lock;   /* serialize */
+       cfs_list_t              crpc_list;      /* chain on user's lists */
+       spinlock_t              crpc_lock;      /* serialize */
         int                  crpc_service;
         cfs_atomic_t         crpc_refcount;
         int                  crpc_timeout; /* # seconds to wait for reply */
@@ -273,7 +275,7 @@ do {                                                                    \
 /* CPU partition data of srpc service */
 struct srpc_service_cd {
        /** serialize */
-       cfs_spinlock_t          scd_lock;
+       spinlock_t              scd_lock;
        /** backref to service */
        struct srpc_service     *scd_svc;
        /** event buffer */
@@ -338,6 +340,7 @@ typedef struct {
         lst_sid_t         sn_id;      /* unique identifier */
         unsigned int      sn_timeout; /* # seconds' inactivity to expire */
         int               sn_timer_active;
+       unsigned int      sn_features;
         stt_timer_t       sn_timer;
         cfs_list_t        sn_batches; /* list of batches */
         char              sn_name[LST_NAME_SIZE];
@@ -381,18 +384,19 @@ typedef struct sfw_test_instance {
         int                     tsi_concur;          /* concurrency */
         int                     tsi_loop;            /* loop count */
 
-        /* status of test instance */
-        cfs_spinlock_t          tsi_lock;         /* serialize */
+       /* status of test instance */
+       spinlock_t              tsi_lock;         /* serialize */
         int                     tsi_stopping:1;   /* test is stopping */
         cfs_atomic_t            tsi_nactive;      /* # of active test unit */
         cfs_list_t              tsi_units;        /* test units */
         cfs_list_t              tsi_free_rpcs;    /* free rpcs */
         cfs_list_t              tsi_active_rpcs;  /* active rpcs */
 
-        union {
-                test_bulk_req_t bulk;             /* bulk parameter */
-                test_ping_req_t ping;             /* ping parameter */
-        } tsi_u;
+       union {
+               test_ping_req_t         ping;     /* ping parameter */
+               test_bulk_req_t         bulk_v0;  /* bulk parameter */
+               test_bulk_req_v1_t      bulk_v1;  /* bulk v1 parameter */
+       } tsi_u;
 } sfw_test_instance_t;
 
 /* XXX: trailing (CFS_PAGE_SIZE % sizeof(lnet_process_id_t)) bytes at
@@ -418,17 +422,20 @@ typedef struct sfw_test_case {
 } sfw_test_case_t;
 
 srpc_client_rpc_t *
-sfw_create_rpc(lnet_process_id_t peer, int service, int nbulkiov, int bulklen,
-               void (*done) (srpc_client_rpc_t *), void *priv);
-int sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer,
-                        int nblk, int blklen, srpc_client_rpc_t **rpc);
+sfw_create_rpc(lnet_process_id_t peer, int service,
+              unsigned features, int nbulkiov, int bulklen,
+              void (*done) (srpc_client_rpc_t *), void *priv);
+int sfw_create_test_rpc(sfw_test_unit_t *tsu,
+                       lnet_process_id_t peer, unsigned features,
+                       int nblk, int blklen, srpc_client_rpc_t **rpc);
 void sfw_abort_rpc(srpc_client_rpc_t *rpc);
 void sfw_post_rpc(srpc_client_rpc_t *rpc);
 void sfw_client_rpc_done(srpc_client_rpc_t *rpc);
 void sfw_unpack_message(srpc_msg_t *msg);
 void sfw_free_pages(srpc_server_rpc_t *rpc);
 void sfw_add_bulk_page(srpc_bulk_t *bk, cfs_page_t *pg, int i);
-int sfw_alloc_pages(srpc_server_rpc_t *rpc, int cpt, int npages, int sink);
+int sfw_alloc_pages(srpc_server_rpc_t *rpc, int cpt, int npages, int len,
+                   int sink);
 int sfw_make_session (srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply);
 
 srpc_client_rpc_t *
@@ -439,7 +446,8 @@ srpc_create_client_rpc(lnet_process_id_t peer, int service,
 void srpc_post_rpc(srpc_client_rpc_t *rpc);
 void srpc_abort_rpc(srpc_client_rpc_t *rpc, int why);
 void srpc_free_bulk(srpc_bulk_t *bk);
-srpc_bulk_t *srpc_alloc_bulk(int cpt, int npages, int sink);
+srpc_bulk_t *srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len,
+                            int sink);
 int srpc_send_rpc(swi_workitem_t *wi);
 int srpc_send_reply(srpc_server_rpc_t *rpc);
 int srpc_add_service(srpc_service_t *sv);
@@ -543,7 +551,7 @@ srpc_init_client_rpc (srpc_client_rpc_t *rpc, lnet_process_id_t peer,
         CFS_INIT_LIST_HEAD(&rpc->crpc_list);
        swi_init_workitem(&rpc->crpc_wi, rpc, srpc_send_rpc,
                          lst_sched_test[lnet_cpt_of_nid(peer.nid)]);
-        cfs_spin_lock_init(&rpc->crpc_lock);
+       spin_lock_init(&rpc->crpc_lock);
         cfs_atomic_set(&rpc->crpc_refcount, 1); /* 1 ref for caller */
 
         rpc->crpc_dest         = peer;
@@ -607,18 +615,18 @@ int selftest_wait_events(void);
 
 #endif
 
-#define lst_wait_until(cond, lock, fmt, ...)                            \
-do {                                                                    \
-        int __I = 2;                                                    \
-        while (!(cond)) {                                               \
-                CDEBUG(IS_PO2(++__I) ? D_WARNING : D_NET,               \
-                       fmt, ## __VA_ARGS__);                            \
-                cfs_spin_unlock(&(lock));                               \
-                                                                        \
-                selftest_wait_events();                                 \
-                                                                        \
-                cfs_spin_lock(&(lock));                                 \
-        }                                                               \
+#define lst_wait_until(cond, lock, fmt, ...)                           \
+do {                                                                   \
+       int __I = 2;                                                    \
+       while (!(cond)) {                                               \
+               CDEBUG(IS_PO2(++__I) ? D_WARNING : D_NET,               \
+                      fmt, ## __VA_ARGS__);                            \
+               spin_unlock(&(lock));                                   \
+                                                                       \
+               selftest_wait_events();                                 \
+                                                                       \
+               spin_lock(&(lock));                                     \
+       }                                                               \
 } while (0)
 
 static inline void