diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-03-28 08:23:08 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 10:45:08 -0500 |
commit | 9f5bdc339e3becd85aa8add305d794b0b1ec8996 (patch) | |
tree | a52dcd2faa3fa88d9d5caf65003c1b2ae56f52d9 /drivers/block/drbd/drbd_int.h | |
parent | 52b061a44021ca11ee2fd238040e91341ff8066d (diff) |
drbd: Replace and remove old primitives
Centralize sock->mutex locking and unlocking in [drbd|conn]_prepare_command()
and [drbd|conn]_send_comman().
Therefore all *_send_* functions are touched to use these primitives instead
of drbd_get_data_sock()/drbd_put_data_sock() and former helper functions.
That change makes the *_send_* functions more standardized.
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_int.h')
-rw-r--r-- | drivers/block/drbd/drbd_int.h | 60 |
1 files changed, 3 insertions, 57 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index 729c96fc0c87..663f7b611756 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
@@ -1060,22 +1060,6 @@ static inline struct drbd_conf *vnr_to_mdev(struct drbd_tconn *tconn, int vnr) | |||
1060 | return (struct drbd_conf *)idr_find(&tconn->volumes, vnr); | 1060 | return (struct drbd_conf *)idr_find(&tconn->volumes, vnr); |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | static inline int drbd_get_data_sock(struct drbd_tconn *tconn) | ||
1064 | { | ||
1065 | mutex_lock(&tconn->data.mutex); | ||
1066 | if (!tconn->data.socket) { | ||
1067 | /* Disconnected. */ | ||
1068 | mutex_unlock(&tconn->data.mutex); | ||
1069 | return -EIO; | ||
1070 | } | ||
1071 | return 0; | ||
1072 | } | ||
1073 | |||
1074 | static inline void drbd_put_data_sock(struct drbd_tconn *tconn) | ||
1075 | { | ||
1076 | mutex_unlock(&tconn->data.mutex); | ||
1077 | } | ||
1078 | |||
1079 | /* | 1063 | /* |
1080 | * function declarations | 1064 | * function declarations |
1081 | *************************/ | 1065 | *************************/ |
@@ -1118,13 +1102,6 @@ extern int _conn_send_state_req(struct drbd_tconn *, int vnr, enum drbd_packet c | |||
1118 | union drbd_state, union drbd_state); | 1102 | union drbd_state, union drbd_state); |
1119 | extern int _drbd_send_state(struct drbd_conf *mdev); | 1103 | extern int _drbd_send_state(struct drbd_conf *mdev); |
1120 | extern int drbd_send_state(struct drbd_conf *mdev); | 1104 | extern int drbd_send_state(struct drbd_conf *mdev); |
1121 | extern int _conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct drbd_socket *sock, | ||
1122 | enum drbd_packet cmd, struct p_header *h, size_t size, | ||
1123 | unsigned msg_flags); | ||
1124 | extern int conn_send_cmd(struct drbd_tconn *tconn, int vnr, struct drbd_socket *sock, | ||
1125 | enum drbd_packet cmd, struct p_header *h, size_t size); | ||
1126 | extern int conn_send_cmd2(struct drbd_tconn *tconn, enum drbd_packet cmd, | ||
1127 | char *data, size_t size); | ||
1128 | extern int drbd_send_sync_param(struct drbd_conf *mdev); | 1105 | extern int drbd_send_sync_param(struct drbd_conf *mdev); |
1129 | extern void drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr, | 1106 | extern void drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr, |
1130 | u32 set_size); | 1107 | u32 set_size); |
@@ -1149,7 +1126,7 @@ extern int drbd_send_ov_request(struct drbd_conf *mdev,sector_t sector,int size) | |||
1149 | 1126 | ||
1150 | extern int drbd_send_bitmap(struct drbd_conf *mdev); | 1127 | extern int drbd_send_bitmap(struct drbd_conf *mdev); |
1151 | extern void drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode); | 1128 | extern void drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode); |
1152 | extern int conn_send_sr_reply(struct drbd_tconn *tconn, enum drbd_state_rv retcode); | 1129 | extern void conn_send_sr_reply(struct drbd_tconn *tconn, enum drbd_state_rv retcode); |
1153 | extern void drbd_free_bc(struct drbd_backing_dev *ldev); | 1130 | extern void drbd_free_bc(struct drbd_backing_dev *ldev); |
1154 | extern void drbd_mdev_cleanup(struct drbd_conf *mdev); | 1131 | extern void drbd_mdev_cleanup(struct drbd_conf *mdev); |
1155 | void drbd_print_uuids(struct drbd_conf *mdev, const char *text); | 1132 | void drbd_print_uuids(struct drbd_conf *mdev, const char *text); |
@@ -1885,26 +1862,6 @@ static inline void request_ping(struct drbd_tconn *tconn) | |||
1885 | wake_asender(tconn); | 1862 | wake_asender(tconn); |
1886 | } | 1863 | } |
1887 | 1864 | ||
1888 | static inline int _drbd_send_cmd(struct drbd_conf *mdev, struct drbd_socket *sock, | ||
1889 | enum drbd_packet cmd, struct p_header *h, size_t size, | ||
1890 | unsigned msg_flags) | ||
1891 | { | ||
1892 | return _conn_send_cmd(mdev->tconn, mdev->vnr, sock, cmd, h, size, msg_flags); | ||
1893 | } | ||
1894 | |||
1895 | static inline int drbd_send_cmd(struct drbd_conf *mdev, struct drbd_socket *sock, | ||
1896 | enum drbd_packet cmd, struct p_header *h, size_t size) | ||
1897 | { | ||
1898 | return conn_send_cmd(mdev->tconn, mdev->vnr, sock, cmd, h, size); | ||
1899 | } | ||
1900 | |||
1901 | static inline int drbd_send_short_cmd(struct drbd_conf *mdev, | ||
1902 | enum drbd_packet cmd) | ||
1903 | { | ||
1904 | struct p_header h; | ||
1905 | return drbd_send_cmd(mdev, &mdev->tconn->data, cmd, &h, sizeof(h)); | ||
1906 | } | ||
1907 | |||
1908 | extern void *conn_prepare_command(struct drbd_tconn *, struct drbd_socket *); | 1865 | extern void *conn_prepare_command(struct drbd_tconn *, struct drbd_socket *); |
1909 | extern void *drbd_prepare_command(struct drbd_conf *, struct drbd_socket *); | 1866 | extern void *drbd_prepare_command(struct drbd_conf *, struct drbd_socket *); |
1910 | extern int conn_send_command(struct drbd_tconn *, struct drbd_socket *, | 1867 | extern int conn_send_command(struct drbd_tconn *, struct drbd_socket *, |
@@ -1916,19 +1873,8 @@ extern int drbd_send_command(struct drbd_conf *, struct drbd_socket *, | |||
1916 | 1873 | ||
1917 | extern int drbd_send_ping(struct drbd_tconn *tconn); | 1874 | extern int drbd_send_ping(struct drbd_tconn *tconn); |
1918 | extern int drbd_send_ping_ack(struct drbd_tconn *tconn); | 1875 | extern int drbd_send_ping_ack(struct drbd_tconn *tconn); |
1919 | 1876 | extern int drbd_send_state_req(struct drbd_conf *, union drbd_state, union drbd_state); | |
1920 | static inline int drbd_send_state_req(struct drbd_conf *mdev, | 1877 | extern int conn_send_state_req(struct drbd_tconn *, union drbd_state, union drbd_state); |
1921 | union drbd_state mask, union drbd_state val) | ||
1922 | { | ||
1923 | return _conn_send_state_req(mdev->tconn, mdev->vnr, P_STATE_CHG_REQ, mask, val); | ||
1924 | } | ||
1925 | |||
1926 | static inline int conn_send_state_req(struct drbd_tconn *tconn, | ||
1927 | union drbd_state mask, union drbd_state val) | ||
1928 | { | ||
1929 | enum drbd_packet cmd = tconn->agreed_pro_version < 100 ? P_STATE_CHG_REQ : P_CONN_ST_CHG_REQ; | ||
1930 | return _conn_send_state_req(tconn, 0, cmd, mask, val); | ||
1931 | } | ||
1932 | 1878 | ||
1933 | static inline void drbd_thread_stop(struct drbd_thread *thi) | 1879 | static inline void drbd_thread_stop(struct drbd_thread *thi) |
1934 | { | 1880 | { |