drbd: Minimal struct drbd_tconn
[linux-block.git] / drivers / block / drbd / drbd_int.h
index 5874357b0f9cd822879ba067ab277a571a7a79e1..1f486f001dfddbffd3829d57ba8fb72ad0d3be81 100644 (file)
@@ -94,6 +94,7 @@ extern char usermode_helper[];
 #define UUID_NEW_BM_OFFSET ((u64)0x0001000000000000ULL)
 
 struct drbd_conf;
+struct drbd_tconn;
 
 
 /* to shorten dev_warn(DEV, "msg"); and relatives statements */
@@ -102,12 +103,18 @@ struct drbd_conf;
 #define D_ASSERT(exp)  if (!(exp)) \
         dev_err(DEV, "ASSERT( " #exp " ) in %s:%d\n", __FILE__, __LINE__)
 
-#define ERR_IF(exp) if (({                                             \
-       int _b = (exp) != 0;                                            \
-       if (_b) dev_err(DEV, "ASSERT FAILED: %s: (%s) in %s:%d\n",      \
-                       __func__, #exp, __FILE__, __LINE__);            \
-       _b;                                                             \
-       }))
+/**
+ * expect  -  Make an assertion
+ *
+ * Unlike the assert macro, this macro returns a boolean result.
+ */
+#define expect(exp) ({                                                         \
+               bool _bool = (exp);                                             \
+               if (!_bool)                                                     \
+                       dev_err(DEV, "ASSERTION %s FAILED in %s\n",             \
+                               #exp, __func__);                                \
+               _bool;                                                          \
+               })
 
 /* Defines to control fault insertion */
 enum {
@@ -649,10 +656,10 @@ union p_polymorph {
 
 /**********************************************************************/
 enum drbd_thread_state {
-       None,
-       Running,
-       Exiting,
-       Restarting
+       NONE,
+       RUNNING,
+       EXITING,
+       RESTARTING
 };
 
 struct drbd_thread {
@@ -954,7 +961,18 @@ struct fifo_buffer {
        unsigned int size;
 };
 
+struct drbd_tconn {                    /* is a resource from the config file */
+       char *name;                     /* Resource name */
+       struct list_head all_tconn;     /* List of all drbd_tconn, prot by global_state_lock */
+       struct drbd_conf *volume0;      /* TODO: Remove me again */
+
+       struct net_conf *net_conf;      /* protected by get_net_conf() and put_net_conf() */
+};
+
 struct drbd_conf {
+       struct drbd_tconn *tconn;
+       int vnr;                        /* volume number within the connection */
+
        /* things that are stored as / read from meta data on disk */
        unsigned long flags;
 
@@ -1490,6 +1508,9 @@ extern rwlock_t global_state_lock;
 extern struct drbd_conf *drbd_new_device(unsigned int minor);
 extern void drbd_free_mdev(struct drbd_conf *mdev);
 
+struct drbd_tconn *drbd_new_tconn(char *name);
+extern void drbd_free_tconn(struct drbd_tconn *tconn);
+
 extern int proc_details;
 
 /* drbd_req */
@@ -2031,21 +2052,21 @@ static inline void drbd_thread_restart_nowait(struct drbd_thread *thi)
  * or implicit barrier packets as necessary.
  * increased:
  *  w_send_barrier
- *  _req_mod(req, queue_for_net_write or queue_for_net_read);
+ *  _req_mod(req, QUEUE_FOR_NET_WRITE or QUEUE_FOR_NET_READ);
  *    it is much easier and equally valid to count what we queue for the
  *    worker, even before it actually was queued or send.
  *    (drbd_make_request_common; recovery path on read io-error)
  * decreased:
  *  got_BarrierAck (respective tl_clear, tl_clear_barrier)
- *  _req_mod(req, data_received)
+ *  _req_mod(req, DATA_RECEIVED)
  *     [from receive_DataReply]
- *  _req_mod(req, write_acked_by_peer or recv_acked_by_peer or neg_acked)
+ *  _req_mod(req, WRITE_ACKED_BY_PEER or RECV_ACKED_BY_PEER or NEG_ACKED)
  *     [from got_BlockAck (P_WRITE_ACK, P_RECV_ACK)]
  *     for some reason it is NOT decreased in got_NegAck,
  *     but in the resulting cleanup code from report_params.
  *     we should try to remember the reason for that...
- *  _req_mod(req, send_failed or send_canceled)
- *  _req_mod(req, connection_lost_while_pending)
+ *  _req_mod(req, SEND_FAILED or SEND_CANCELED)
+ *  _req_mod(req, CONNECTION_LOST_WHILE_PENDING)
  *     [from tl_clear_barrier]
  */
 static inline void inc_ap_pending(struct drbd_conf *mdev)